private HibernateCallback getHibernateCallbackForGetObjectProjection(final BaseObject baseObject, final List<String> fields) {
return new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Criteria criteria = session.createCriteria(baseObject.getClass());
boolean bool = false;
bool = addCriteria(baseObject, criteria, new HashMap<String, Criteria>());
if(bool==false){
return null;
}
ProjectionList proList = Projections.projectionList();
for(int i=0;i<fields.size();i++){
// String propertyName=fields.get(i);
proList.add(Projections.property(fields.get(i)));
log.debug("q1"+proList);
}
criteria.setProjection(proList);
log.debug("query1"+criteria.setProjection(proList));
criteria.setResultTransformer(Transformers.aliasToBean(baseObject.getClass()));
log.debug("query"+criteria.list());
List<BaseObject> result = criteria.list();
if(result!=null && result.size()>0){
return result.get(0);
}else{
return null;
}
}
};
}
log output
query1CriteriaImpl
(com.cpt.his.model.DefineReport:this[][defineReportCode=P002][defineReportDetails1, defineReportHeading])
DEBUG [btpool0-1] SQL.log(401) |
select this_.DFC_DETAILS1 as y0_, this_.DFC_HEAD as y1_ from DEFREPO this_ where this_.DF_CODE=?
DEBUG [btpool0-1] DefaultDaoHibernate.doInHibernate(146) |
query[com.cpt.his.model.DefineReport@1900624[defineReportStatus=<null>,defineReportPdCode=<null>,defineReportDetails1=<null>,defineReportDescription=<null>,defineReportEndDate=<null>,defineReportHeading=<null>,reportDefs=[],defineReportCode=<null>,defineReportUSCode=<null>,defineReportAlias=<null>,defineReportDetails=<null>]]
|