[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-530) Allow application of filters on subqueries

Steve Ebersole (JIRA) noreply at atlassian.com
Tue Sep 23 13:08:09 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-530?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=31269#action_31269 ] 

Steve Ebersole commented on HHH-530:
------------------------------------

Criteria is inherently different than HQL ;)

And they are very different in precisely the respect causing issues here : parameters.

I wrote a new Criteria query to demonstrate:

		Session session = openSession();
		session.beginTransaction();
		session.enableFilter( "fulfilledOrders" ).setParameter( "asOfDate", testData.lastMonth.getTime() );
		session.enableFilter( "regionlist" ).setParameterList( "regions", new String[] { "APAC" } );

		DetachedCriteria subquery = DetachedCriteria.forClass( Salesperson.class )
				.setProjection( Property.forName( "name" ) );
		List result = session.createCriteria( Order.class )
				.add( Subqueries.in( "steve", subquery ) )
				.list();
		assertEquals( 1, result.size() );

which works.  And then converted it to HQL:

		final String queryString = "from Order o where :salesPersonName in ( select sp.name from Salesperson sp )";
		session.enableFilter( "fulfilledOrders" ).setParameter( "asOfDate", testData.lastMonth.getTime() );
		session.enableFilter( "regionlist" ).setParameterList( "regions", new String[] { "APAC" } );
		result = session.createQuery( queryString ).setString( "salesPersonName", "steve" ).list();
		assertEquals( 1, result.size() );

which fails; or:

		final String queryString = "from Order o where ? in ( select sp.name from Salesperson sp )";
		session.enableFilter( "fulfilledOrders" ).setParameter( "asOfDate", testData.lastMonth.getTime() );
		session.enableFilter( "regionlist" ).setParameterList( "regions", new String[] { "APAC" } );
		result = session.createQuery( queryString ).setString( 0, "steve" ).list();
		assertEquals( 1, result.size() );

which also fails.


> Allow application of filters on subqueries
> ------------------------------------------
>
>                 Key: HHH-530
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-530
>             Project: Hibernate Core
>          Issue Type: Patch
>          Components: core
>            Reporter: Gavin King
>            Assignee: Steve Ebersole
>             Fix For: 3.3.x
>
>         Attachments: HHH-530.3.3.SP1.patch, HHH-530.Additional.Subquery.patch, HHH-530.patch, hibernate_filter_fix-3.0.5.patch, hibernate_filter_fix-3.0.5_14.patch, SubqueriesWithFiltersTest.patch
>
>
> Currently filter conditions are applied in subselects, they should not be.

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