]
Emmanuel Bernard updated HHH-993:
---------------------------------
Comment: was deleted
(was: [cheap airline
Criteria subquery without projection fails throwing
NullPointerException
------------------------------------------------------------------------
Key: HHH-993
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-993
Project: Hibernate Core
Issue Type: Improvement
Components: core
Reporter: Johannes Rudolph
Priority: Minor
If you use a subquery in a criteria query and there is no projection, the execution of
the query will fail by throwing a NullPointerException:
Caused by: java.lang.NullPointerException
at
org.hibernate.loader.criteria.CriteriaQueryTranslator.getProjectedTypes(Crit
eriaQueryTranslator.java:298)
at
org.hibernate.criterion.SubqueryExpression.toSqlString(SubqueryExpression.ja
va:56)
at
org.hibernate.criterion.LogicalExpression.toSqlString(LogicalExpression.java
:39)
org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(Crit
eriaQueryTranslator.java:314)
...
I think it is expected behaviour that restrictions only work on 1-dimensional return
values of subqueries so it would be nice if Hibernate would mention that somewhere.
It would be nice if you could just write:
Criteria crit = dbSession.createCriteria(Bla.class);
DetachedCriteria detachedCrit = DetachedCriteria.forClass(Blub.class).add(
Restrictions.eq("condition", Boolean.FALSE));
crit.add( Restrictions.or( Restrictions.isNull("superBlub"),
Subqueries.in("superBlub", detachedCrit ) ) );
since Hibernate entities could be seen as "entities" so Hibernate should
automatically transform it into:
DetachedCriteria detachedCrit = DetachedCriteria.forClass(Blub.class).add(
Restrictions.eq("condition", Boolean.FALSE))
.setProjection( Projections.id() );
crit.add( Restrictions.or( Restrictions.isNull("superBlub"),
Subqueries.propertyIn("ueberPartner", detachedCrit ) ) );
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: