}
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.length + 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.length + 1; x++) {
if (x == 1) {
sql.append(" ( tree.parent = ? and ");
sql.append(" tree.child = " + tableName + ".inode ) and ");
} else {
sql.append(" (tree" + x + ".parent = ? and ");
sql.append(" tree" + x + ".child = " + tableName + ".inode ) and ");
}
}
String query = sql.toString();
query = query.substring(0, query.lastIndexOf("and"));
// Validate condition
condition = (UtilMethods.isSet(condition) ? " and " + condition : "");
// Validate order
orderBy = (UtilMethods.isSet(orderBy) ? " order by " + orderBy : "");
// Create the final query
query += condition + orderBy;
// Set the query
dh.setSQLQuery(query);
for (int x = 0; x < inodes.length; x++) {
dh.setParam(inodes[x]);
}
return dh.list();
} catch (Exception e) {
Logger.debug(InodeFactory.class, "getChildrenClassByConditionAndOrderBy failed:" + e, e);
// throw new DotRuntimeException(e.toString());
}