java - hibernate subquery throwing Null Pointer Exception -
i trying fire subquery hibernate, showing npe:-(anyone know how resolve it? below code:
detachedcriteria criteria = detachedcriteria.forclass(my.class,"a"); criteria.createalias("a.a", "a"); criteria.createalias("a.b", "b"); if(cvalue !=null && cvalue.size()>0){ criteria.add(restrictions.in("b.c", cvalue)); } if(stringutils.isnotempty(commoditylist)){ detachedcriteria commcriteria = detachedcriteria.forclass(my.class,"a1"); commcriteria.createalias("a1.a", "a1"); commcriteria.add(restrictions.in("a1.name", commoditylist.split(","))); criteria.add(subqueries.propertyin("b.c", commcriteria)); } criteria.addorder(order.asc("b.c")); return gethibernatetemplate().findbycriteria(criteria);
stack trace:
java.lang.nullpointerexception @ org.hibernate.loader.criteria.criteriaquerytranslator.getprojectedtypes(criteriaquerytranslator.java:318) @ org.hibernate.criterion.subqueryexpression.tosqlstring(subqueryexpression.java:56) @ org.hibernate.loader.criteria.criteriaquerytranslator.getwherecondition(criteriaquerytranslator.java:334) @ org.hibernate.loader.criteria.criteriajoinwalker.<init>(criteriajoinwalker.java:82) @ org.hibernate.loader.criteria.criterialoader.<init>(criterialoader.java:67) @ org.hibernate.impl.sessionimpl.list(sessionimpl.java:1550) @ org.hibernate.impl.criteriaimpl.list(criteriaimpl.java:283) @ org.springframework.orm.hibernate3.hibernatetemplate$36.doinhibernate(hibernatetemplate.java:1065) @ org.springframework.orm.hibernate3.hibernatetemplate.doexecute(hibernatetemplate.java:419) @ org.springframework.orm.hibernate3.hibernatetemplate.executewithnativesession(hibernatetemplate.java:374) @ org.springframework.orm.hibernate3.hibernatetemplate.findbycriteria(hibernatetemplate.java:1055) @ org.springframework.orm.hibernate3.hibernatetemplate.findbycriteria(hibernatetemplate.java:1048) @ com.boeing.kmapi.base.skillset.dao.impl.essskillsetcommmapdaoimpl.getessskillsetcommmapforskillsetidlist(essskillsetcommmapdaoimpl.java:51) @ com.boeing.kmapi.base.skillset.service.impl.essgenericreportserviceimpl.filtercommoditydetails(essgenericreportserviceimpl.java:87) @ com.boeing.kmapi.base.skillset.service.impl.essgenericreportserviceimpl.getgenericreport(essgenericreportserviceimpl.java:79) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597)
the issue resoled adding projection inner query.
commcriteria.createalias("a1.b", "b1"); commcriteria.setprojection(projections.projectionlist().add(projections.property("b1.c")));
the issue resoled adding projection inner query.
commcriteria.createalias("a1.b", "b1"); commcriteria.setprojection(projections.projectionlist().add(projections.property("b1.c")));
Comments
Post a Comment