I am getting this nullpointer When I add a simple subquery. Am I doing something wrong or is this a bug?
Code:
java.lang.NullPointerException
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getProjectedTypes(CriteriaQueryTranslator.java:341)
at org.hibernate.criterion.SubqueryExpression.createAndSetInnerQuery(SubqueryExpression.java:136)
at org.hibernate.criterion.SubqueryExpression.toSqlString(SubqueryExpression.java:71)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:357)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:102)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:82)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:91)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1577)
Code:
DetachedCriteria subquery = DetachedCriteria.forClass(Wtns.class, "wtns");
subquery.add(Restrictions.eq("productid", "303"));
//Restrictions.like("wtns.pk.wtn", ident)
SimpleExpression btn = Restrictions.like("trans."+BY_BTN.code, ident);
Criterion wtns = Property.forName("trans.tpvid").in(subquery);
LogicalExpression exp = Restrictions.or(btn, wtns);
criteria.add(wtns);
If I change the last line from criteria.add(wtns) to criteria.add(btn), everything works fine. My goal is to be using the criteria.add(exp) but I can't seem to get that working.
thanks,
Dean