[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5518) @ManyToOne(fetch=FetchType.LAZY) annotation generates always an inner join into a query
Mathias Arens (JIRA)
noreply at atlassian.com
Tue Aug 31 11:11:18 EDT 2010
@ManyToOne(fetch=FetchType.LAZY) annotation generates always an inner join into a query
---------------------------------------------------------------------------------------
Key: HHH-5518
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5518
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.5.5
Environment: Java 1.6.0_20, Hibernate-EntityManager 3.5.5-Final, HSQLDB, Oracle 11g
Reporter: Mathias Arens
Attachments: HibernateTest.zip
Hibernate generates a left outer join *plus* a inner join for the same relation into my query.
I have a simple @ManyToOne annotation for a reference from a alert object to a user object:
{code}
public class Alert {
[...]
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "RESPONSIBLE_USER_ID")
private UserDO responsibleUser;
[...]
}
{code}
My jpql query is a little more complex:
{code:sql}
select rra from AlertWithResponsibleUserDO rra left join rra.responsibleUser, TeamDO t, BusinessPartnerSearchDO bps join t.teamMembers tm where rra.businessPartnerId = bps.businessPartnerId and (bps.ratingObjectType = 'STANDARD' or bps.ratingObjectType is null) and bps.analyst = tm.organisationalUnit and t.id = :teamId and rra.severity in (:severities) and bps.locale = :locale and bps.localeBpType = :localeBpType"
{code}
The central outer join definition is this:
{code}
AlertWithResponsibleUserDO rra left join rra.responsibleUser
{code}
But Hibernate keeps creating a left outer join *and* a inner join for this relation whatever I do:
{code:sql}
from
V440_R_ALERTS_WITH_RESP_USER alertwithr0_
left outer join
V004_USER userdo1_
on alertwithr0_.F440_F004_RESPONSIBLE_USER_ID=userdo1_.F004_ID
inner join
V004_USER userdo6_
on alertwithr0_.F440_F004_RESPONSIBLE_USER_ID=userdo6_.F004_ID cross
{code}
I already tried different queries and @ManyToOne attributes but none of them affected the sql outcome. I tried a similar relation in a different context but there it worked. Hibernate generated only a left outer join into the sql query. But I don't know which settings generate the two joins on the same relation.
I have added a simple maven test project. Just unzip the HibernateTest.zip and run 'mvn test'. A starting point for further testing could be the AppTest.testManyToOneInnerJoinIssue() test routine.
Thanks for your help in advance.
--
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