// init
if(qry==null){
ClassMetadata md = ((HibernateORMEngine)session.getEngine()).getSessionFactory(pc).getClassMetadata(getEntityName(cfc));
//Struct columnsInfo= engine.getTableInfo(session.getDatasourceConnection(),toEntityName(engine, cfc),session.getEngine());
Array names=CommonUtil.createArray();
Array types=CommonUtil.createArray();
String name;
//ColumnInfo ci;
int t;
Object obj;
Struct sct;
String fieldType;
for(int i=0;i<properties.length;i++){
obj = properties[i].getMetaData();
if(obj instanceof Struct) {
sct=(Struct) obj;
fieldType = CommonUtil.toString(sct.get(CommonUtil.FIELDTYPE,null),null);
if("one-to-many".equalsIgnoreCase(fieldType) || "many-to-many".equalsIgnoreCase(fieldType) || "many-to-one".equalsIgnoreCase(fieldType) || "one-to-one".equalsIgnoreCase(fieldType))
continue;
}
name=HibernateUtil.validateColumnName(md, properties[i].getName(),null);
//if(columnsInfo!=null)ci=(ColumnInfo) columnsInfo.get(name,null);
//else ci=null;
names.append(name);
if(name!=null){
t=HibernateCaster.toSQLType(HibernateUtil.getPropertyType(md, name).getName(), NULL);
if(t==NULL)
types.append("object");
else
types.append(SQLCaster.toStringType(t));
}
else
types.append("object");
}
qry=CommonUtil.createQuery(names,types,0,getEntityName(cfc));
}