[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3872) Criteria on alias causes partial collection materialization

Adrian Moos (JIRA) noreply at atlassian.com
Wed Apr 22 07:36:17 EDT 2009


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

Adrian Moos commented on HHH-3872:
----------------------------------

Preliminary analysis: It appears hibernate populates the children sets from the result set of the main sql-query, whose where-clause restricts the children to be returned:

2009-04-22 11:26:56,898 [http-8080-Processor22] org.hibernate.SQL
DEBUG: [127.0.0.1 / svv] (main query, with a single join to table CHILDREN and "WHERE child.businessKey = ?")
2009-04-22 11:29:51,878 [http-8080-Processor22] org.hibernate.loader.Loader
DEBUG: [127.0.0.1 / svv] found row of collection: [Parent.children#2444884]

org.hibernate.SQL logs no follow-up sql-query accessing the children table before the query returns.

> Criteria on alias causes partial collection materialization
> -----------------------------------------------------------
>
>                 Key: HHH-3872
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3872
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: query-criteria
>    Affects Versions: 3.3.0.CR1
>            Reporter: Adrian Moos
>
> I have a parent entity with a one-to-many assocation to a child entity:
> <hibernate-mapping package="ch.bedag.a11.ccinfo.business.entity" default-lazy="false">
> 	<class name="Parent" table="PARENT">
> 		<id name="id" type="long" column="ID" unsaved-value="null">
> 			<generator class="sequence">
> 				<param name="sequence">SEQ_T_PARENT</param>
> 			</generator>
> 		</id>
> 		<set name="children" cascade="all-delete-orphan" inverse="true">
> 			<key column="PARENT_ID" foreign-key="CHILD_FK1"/>
> 			<one-to-many class="Child"/>
> 		</set>
> 	</class>
> 	
> 	<class name="Child" 
> 		<id name="id" type="long" column="ID" unsaved-value="null">
> 			<generator class="sequence">
> 				<param name="sequence">SEQ_T_CHILD</param>
> 			</generator>
> 		</id>
> 		
> 		<property name="businessKey" column="BUSINESSKEY" not-null="true"/>
> 	</class>
> </hibernate-mapping>
> I then do:
>         Criteria parentCriteria = aSession.createCriteria(Parent.class);                
>         parentCriteria.createAlias("children", "c", CriteriaSpecification.LEFT_JOIN);
>         parentCriteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
>                 
>         parentCriteria.add(Restrictions.eq("c.businessKey", 123456789));
>         
>         List parents = parentCriteria.list();
> Expected behaviour: Since each parent in parents is a materialized entity, I'd expect its children set to contain all its children. 
> Observed behaviour: It contains only children with matching business key.
> Is my expectation correct?

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