Puhong You (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *commented* on HHH-16469 (
https://hibernate.atlassian.net/browse/HHH-16469?atlOrigin=eyJpIjoiMmVkOT...
)
Re: Hibernate repeatedly issues identical SELECT queries to load an optional one-to-one
association (
https://hibernate.atlassian.net/browse/HHH-16469?atlOrigin=eyJpIjoiMmVkOT...
)
Hi, Andrea,
Thanks for looking into this.
I think your test initialization routine failed to establish the agency ↔︎ group and group
↔︎ user association properly. Can you try this instead?
@BeforeAll
public void setUp(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
Agency agency = new Agency( 1, "Test Agency" );
Group group = new Group( 1, "Test Group 1" );
agency.addGroup(group);
for ( int i = 1; i < 9; i++ ) {
User user = new User( i, "User " + i );
agency.addUser(user);
group.addUser(user);
}
session.persist( agency );
}
);
}
This requires a addGroup() method be added to the Agency entity bean –
public void addGroup(Group group){
if (groups == null){
groups = new HashSet<>();
}
groups.add( group );
group.setAgency( this );
}
Please check the database content after the initialization routine to see if the table
contents look ok.
Please let me know if you have any further questions.
(
https://hibernate.atlassian.net/browse/HHH-16469#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16469#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#100222- sha1:cb3bdf0 )