Andrea Boriero (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYWMxNTdmNGRl...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16453?atlOrigin=eyJpIjoiYWMxNT...
) HHH-16453 (
https://hibernate.atlassian.net/browse/HHH-16453?atlOrigin=eyJpIjoiYWMxNT...
) Loading an Entity with two eager collections, produces duplicates when one of the
collection is a a bag (
https://hibernate.atlassian.net/browse/HHH-16453?atlOrigin=eyJpIjoiYWMxNT...
)
Issue Type: Bug Affects Versions: 6.2.0 Assignee: Andrea Boriero (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) Components: hibernate-core Created: 11/Apr/2023 03:43 AM Priority: Major Reporter:
Andrea Boriero (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Given
@Entity(name = "EntityB" )
public static class EntityB {
...
@OneToMany(fetch = FetchType.EAGER)
Collection<EntityC> attributes = new LinkedList<>();
@OneToMany(fetch = FetchType.EAGER)
Set<EntityD> entityDS = new HashSet<>();
}
@Entity(name = "EntityC" )
public static class EntityC {
...
}
@Entity(name = "EntityD" )
public static class EntityD {
...
}
the test
@Test
public void testIt(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
EntityC c = new EntityC( 1l, "c" );
EntityC c1 = new EntityC( 2l, "c1" );
EntityD d = new EntityD( 1l, "d" );
EntityD d1 = new EntityD( 2l, "d1" );
EntityD d2 = new EntityD( 3l, "d2" );
EntityB b = new EntityB( 1l, "b" );
b.addAttribute( c );
b.addAttribute( c1 );
b.addEntityD( d );
b.addEntityD( d1 );
b.addEntityD( d2 );
session.save( c );
session.save( c1 );
session.save( d );
session.save( d1 );
session.save( d2 );
session.save( b );
}
);
scope.inTransaction(
session -> {
EntityB entityB = session.find( EntityB.class, 1l );
assertThat( entityB.getAttributes().size() ).isEqualTo( 2 );
}
);
}
fails because entityB.getAttributes().size() is equal to 6.
(
https://hibernate.atlassian.net/browse/HHH-16453#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16453#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=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100221- sha1:9ff53d8 )