[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2473) fetch="join" and property-ref

Bill Swayze (JIRA) noreply at atlassian.com
Tue Apr 10 15:17:07 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2473?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_26675 ] 

Bill Swayze commented on HHH-2473:
----------------------------------

I am experiencing a similar problem in HQL with many-to-one associations using a property-ref.  The 'one' end of the association is retrieved and partially resolved and saved in entitiesByKey.  In subsequent result set processing, an attempt to resolve the entity in entitiesByUniqueKey is unsuccessful as it is trying to use the pk.  Ultimately, the entity is null in the results of .list().

Consider the following mappings and query:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
	<class name="test.A" 
		   table="a_t">
		<id name="id" column="id" type="java.lang.Integer">
			<generator class="assigned"/>
		</id>
		<many-to-one name="child" class="test.B" column="str_id" property-ref="key" not-null="true"/>
	</class>
</hibernate-mapping>

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping>
	<class name="test.B" 
		   table="b_t">
		<id name="id" column="id" type="java.lang.Integer">
			<generator class="assigned"/>
		</id>
		<property name="data" type="java.lang.String" column="data" not-null="true" length="80" />
		<property name="key" type="java.lang.String" column="str_id" unique="true" not-null="true" length="80" />
	</class>
</hibernate-mapping> 

select aa.id, bb from A aa inner join aa.child bb where aa.id = 1

> fetch="join" and property-ref
> -----------------------------
>
>                 Key: HHH-2473
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2473
>             Project: Hibernate3
>          Issue Type: Improvement
>    Affects Versions: 3.2.1
>         Environment: Version 3.2.1, not DB dependant 
>            Reporter: David CLEMENT
>
> When Hibernate does a fetch join with a property-ref  in a many-to-one, it issues the join SQL query but needs another select to find the associated entity by property-ref.
> It should be able to use the entity fetched in the join instead (maybe this has been done to ensure the unicity of the associated entity, but it introduce a performance issue).

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