[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-993) Criteria subquery without projection fails throwing NullPointerException
Emmanuel Bernard (JIRA)
noreply at atlassian.com
Wed Oct 13 11:08:07 EDT 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-993?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Emmanuel Bernard updated HHH-993:
---------------------------------
Comment: was deleted
(was: [cheap airline tickets|http://getflightsto.com]
[Parenting|http://childcareforums.com]
)
> 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: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list