-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: while using result transformer - object becomes null
PostPosted: Fri Jul 04, 2008 2:00 am 
Newbie

Joined: Fri Jun 27, 2008 12:15 am
Posts: 5
Location: India
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>]]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.