[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-4924) Unnecessary "left outer join". Probably this "left outer join" can be eliminated. OneToOne when optional=true and LAZY
Adam Wozniak (JIRA)
noreply at atlassian.com
Tue Feb 16 18:47:47 EST 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4924?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Adam Wozniak updated HHH-4924:
------------------------------
Attachment: PersonPk.java
Person.java
Office.java
> Unnecessary "left outer join". Probably this "left outer join" can be eliminated. OneToOne when optional=true and LAZY
> ----------------------------------------------------------------------------------------------------------------------
>
> Key: HHH-4924
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4924
> Project: Hibernate Core
> Issue Type: Improvement
> Components: core
> Affects Versions: 3.3.1
> Environment: n/a
> Reporter: Adam Wozniak
> Attachments: CREATE TABLES POSTGRESQL.sql, Office.java, Person.java, PersonPk.java
>
>
> Hi
> Relation between Person and Office is: 1 to {0 or 1}
> There a 3 classes (sources attached):
> * PersonPk
> * Person
> * Office
> SCENARIO
> --------
> final Office office = em.find(Office.class, new PersonPk("adam", "woz"));
> System.out.println(office.getPerson().getZodiac());
> I second line the following SQL is generated:
> select
> person0_.first_name as first1_22_1_,
> person0_.last_name as last2_22_1_,
> person0_.zodiac as zodiac22_1_,
> office1_.first_name as first1_23_0_,
> office1_.last_name as last2_23_0_,
> office1_.address as address23_0_
> from
> PERSON person0_
> left outer join
> OFFICE office1_
> on person0_.first_name=office1_.first_name
> and person0_.last_name=office1_.last_name
> where
> person0_.first_name=?
> and person0_.last_name=?
> But we already know all columns for OFFICE so there is need to loaded them once again. In other words this SQL can be reduced to such SQL:
> select
> person0_.first_name as first1_22_1_,
> person0_.last_name as last2_22_1_,
> person0_.zodiac as zodiac22_1_,
> from
> PERSON person0_
> where
> person0_.first_name=?
> and person0_.last_name=?
> Kind regards,
> Adam Woźniak / Poland
--
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