}
try {
String tableName = ((Inode) c.newInstance()).getType();
HibernateUtil dh = new HibernateUtil(c);
StringBuffer sql = new StringBuffer("SELECT {" + tableName + ".*} from " + tableName + " " + tableName);
for (int x = 1; x < inodes.size() + 1; x++) {
if (x == 1) {
sql.append(", tree tree ");
} else {
sql.append(", tree tree" + x + " ");
}
}
sql.append(", inode " + tableName + "_1_ ");
sql.append(" where "+tableName+"_1_.type = '"+tableName+"' and ");
sql.append(tableName + "_1_.inode = " + tableName + ".inode and ");
for (int x = 1; x < inodes.size() + 1; x++) {
if (x == 1) {
sql.append(" ( tree.parent = ? and ");
sql.append(" tree.child = " + tableName + ".inode ) ");
} else {
sql.append(" and (tree" + x + ".parent = ? and ");
sql.append(" tree" + x + ".child = " + tableName + ".inode ) ");
}
}
// only if we send condition
if (UtilMethods.isSet(condition)) {
sql.append(" and " + condition);
}
// only if we send orderby
if (UtilMethods.isSet(orderBy)) {
sql.append(" order by ");
sql.append(orderBy);
}
dh.setSQLQuery(sql.toString());
for (int x = 0; x < inodes.size(); x++) {
Inode i = (Inode) inodes.get(x);
dh.setParam(i.getInode());
}
if (limit != 0) {
dh.setFirstResult(offset);
dh.setMaxResults(limit);
}
return dh.list();
} catch (Exception e) {
Logger.debug(InodeFactory.class, "getChildrenClassByConditionAndOrderBy failed:" + e, e);
// throw new DotRuntimeException(e.toString());
}