[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3310) Using Nested DetachedCriteria (Sub-Selects) throwing NullPointerException

Roshan Dawrani (JIRA) noreply at atlassian.com
Thu May 29 05:31:33 EDT 2008


Using Nested DetachedCriteria (Sub-Selects) throwing NullPointerException
-------------------------------------------------------------------------

                 Key: HHH-3310
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3310
             Project: Hibernate3
          Issue Type: Bug
    Affects Versions: 3.2.5
         Environment: Hibernate 3.2.5, Oracle 10g
            Reporter: Roshan Dawrani
         Attachments: Nested_Subselects.zip

Hi,
We have come across an issue with the usage of nested subselects in the sql query with hibernate 3.2.5.
	
We get the following exception when there is more than one level of sub-selects in the query :
----------------------------------------------------------------------------------------------------------------------
	java.lang.NullPointerException
		at org.hibernate.criterion.SubqueryExpression.getTypedValues(SubqueryExpression.java:80)
		at org.hibernate.loader.criteria.CriteriaQueryTranslator.getQueryParameters(CriteriaQueryTranslator.java:251)
		at org.hibernate.criterion.SubqueryExpression.toSqlString(SubqueryExpression.java:55)
		at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:334)
		at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:71)
		at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:67)
		at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1550)
		at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
	at NestedDetachedCriteriaTest.testNestedDetachedCriteria(Unknown Source)
----------------------------------------------------------------------------------------------------------------------

The actual query that gets fired is like:
----------------------------------------------------------------------------------------------------------------------
select this_.name as y0_ from cat this_ where this_.name = 
	(select this0__.name as y0_ from cat this0__ where this0__.parent_id = 
		(select this0__.parent_id as y0_ from cat this0__ where this0__.name = 
			(select this0__.name as y0_ from cat this0__ where this0__.cat_id = ?)))
----------------------------------------------------------------------------------------------------------------------
					

We investigated the issue and have fixed it by making some changes in org.hibernate.criterion.SubqueryExpression class. 

The attached file has the following contents:
	1. SubqueryExpression.java - Fix we have made to SubqueryExpression class.
	2. NestedDetachedCriteriaTest.zip - A test case to highlight the nested sub-select issue (testNestedDetachedCriteria).

Regards,
Roshan

-- 
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