Hibernate version: 3.2
For the moment I'm using a Criteria that is working well:
Code:
Session hibernateSession = HibernateUtil.getSessionFactory().getCurrentSession();
Criteria crit = hibernateSession.createCriteria("org.SVM.Hibernate.model.ProductionViewDescription");
crit.createCriteria("creatorDescriptions").add(Restrictions.ilike("familyName","Doe"));
List result = crit.list();
Now I want to detach the criteria about the
creatorDescriptions, so I tried stuff like this:
Code:
Session hibernateSession = HibernateUtil.getSessionFactory().getCurrentSession();
Criteria crit = hibernateSession.createCriteria("org.SVM.Hibernate.model.ProductionViewDescription");
DetachedCriteria creatorCrit = DetachedCriteria.forClass(CreatorDescription.class);
creatorCrit.add(Restrictions.ilike("familyName","Doe"));
crit.add(Subqueries.propertyIn("creatorDescriptions",creatorCrit));
//or
crit.add(Subqueries.exists(creatorCrit));
List result = crit.list();
The subquery alone is working:
Code:
List result = creatorCrit.getExecutableCriteria(hibernateSession).list();
But in both case when putting it in the crit I get following error:
Code:
java.lang.NullPointerException
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getProjectedTypes(CriteriaQueryTranslator.java:317)
at org.hibernate.criterion.SubqueryExpression.toSqlString(SubqueryExpression.java:56)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:333)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:82)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:67)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1514)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
Can someone help me?