[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5291) Hibernate generates several join clauses for same table

Claudio Tagliola (JIRA) noreply at atlassian.com
Tue Mar 20 05:27:50 EDT 2012


    [ https://hibernate.onjira.com/browse/HHH-5291?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46028#comment-46028 ] 

Claudio Tagliola commented on HHH-5291:
---------------------------------------

We have this issue with 3.6.9. Did you ever find a workaround?

> Hibernate generates several join clauses for same table
> -------------------------------------------------------
>
>                 Key: HHH-5291
>                 URL: https://hibernate.onjira.com/browse/HHH-5291
>             Project: Hibernate ORM
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.5.2
>         Environment: Hibernate 3.5.2
>            Reporter: Igor Nikolaev
>
> Suppose you've got a mapping:
>     <class name="Class" table="TABLE1" dynamic-update="true">
>         <id name="id" type="int">
>             <column name="ID" />
>             <generator class="assigned" />
>         </id>
>         
>         <discriminator column="CLASS_TYPE"/>
> 	<property name="property1" type="string" column="PROPERTY1" update="false" insert="false"/>
>         
> 	<join table="TABLE2" optional="true">
> 		<key column="ID" not-null="false"/>
> 		<property name="property2" column="PROPERTY2"/>
> 	</join>
> 		
> 	<subclass name="Subclass" discriminator-value="SUBCLASS">
> 		<join table="TABLE2">
> 			<key column="swift_id"/>
> 			<property name="property3" column="PROPERTY3"/>
> 		</join>
> 	</subclass>
>     </class>
> As you can notice, we join the same table in subclass. 
> Expected result is that Hibernat generates a query like this one: 
>     select
>         this_.ID,
>         this_.PROPERTY1,
>         this_1_.PROPERTY2,
>         this_1_.PROPERTY3
>     from
>         TABLE1 this_ 
>     left inner join
>         TABLE2 this_1_ 
>             on this_.ID=this_1_.ID 
> Instead, Hibernate joins TABLE2 twice and generates the following query:
>     select
>         this_.ID,
>         this_.PROPERTY1,
>         this_1_.PROPERTY2,
>         this_2_.PROPERTY3
>     from
>         TABLE1 this_ 
>     left inner join
>         TABLE2 this_1_ 
>             on this_.ID=this_1_.ID 
>     left outer join
>         TABLE2 this_2_ 
>             on this_.ID=this_2_.ID 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list