[JIRA] (HHH-14084) Lazy property treated as eager when using entity graph
by Konrad (JIRA)
Konrad ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYWMxNTVhZDM2... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-14084?atlOrigin=eyJpIjoiYWMxNT... ) HHH-14084 ( https://hibernate.atlassian.net/browse/HHH-14084?atlOrigin=eyJpIjoiYWMxNT... ) Lazy property treated as eager when using entity graph ( https://hibernate.atlassian.net/browse/HHH-14084?atlOrigin=eyJpIjoiYWMxNT... )
Issue Type: Bug Affects Versions: 5.4.14 Assignee: Unassigned Components: hibernate-core Created: 24/Jun/2020 07:07 AM Priority: Major Reporter: Konrad ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
Two entities have property of same name. In given example Parent and Child entities have properties with name *toys* and only Parent.toys is included in entity graph. After fetching data using entity graph Child.toys are treated as eager fetch.
@NamedEntityGraph(
name = "parentWithToysAndChild" ,
attributeNodes = {
@NamedAttributeNode( "toys" ),
@NamedAttributeNode( "child" )
}
)
Hibernate:
select
parent0_.id as id1_3_0_,
parent0_.child_id as child_id2_3_0_,
child1_.id as id1_0_1_,
toys2_.Parent_id as parent_i1_4_2_,
parenttoy3_.id as toys_id2_4_2_,
parenttoy3_.id as id1_5_3_,
parenttoy3_.name as name2_5_3_,
parenttoy3_.parent_id as parent_i3_5_3_
from
Parent parent0_
left outer join
Child child1_
on parent0_.child_id=child1_.id
left outer join
Parent_ParentToy toys2_
on parent0_.id=toys2_.Parent_id
left outer join
ParentToy parenttoy3_
on toys2_.toys_id=parenttoy3_.id
where
parent0_.id=?
Hibernate:
select
toys0_.Child_id as child_id1_1_0_,
toys0_.toys_id as toys_id2_1_0_,
childtoy1_.id as id1_2_1_,
childtoy1_.child_id as child_id3_2_1_,
childtoy1_.name as name2_2_1_,
child2_.id as id1_0_2_
from
Child_ChildToy toys0_
inner join
ChildToy childtoy1_
on toys0_.toys_id=childtoy1_.id
left outer join
Child child2_
on childtoy1_.child_id=child2_.id
where
toys0_.Child_id=?
Test case repo: https://github.com/MrJavaNoHome/hibernate-orm-entity-graph-redundant-sql
( https://hibernate.atlassian.net/browse/HHH-14084#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-14084#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100130- sha1:b8a2349 )
5 years, 4 months