Andrea Boriero (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNjhjZTQxNDM0...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16184?atlOrigin=eyJpIjoiNjhjZT...
) HHH-16184 (
https://hibernate.atlassian.net/browse/HHH-16184?atlOrigin=eyJpIjoiNjhjZT...
) executing query twice when initializing empty collection (
https://hibernate.atlassian.net/browse/HHH-16184?atlOrigin=eyJpIjoiNjhjZT...
)
Issue Type: Bug Affects Versions: 6.2.0.CR2, 6.1.7 Assignee: Andrea Boriero (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) Components: hibernate-core Created: 14/Feb/2023 07:31 AM Fix Versions: 6.2.0 Priority:
Major Reporter: Andrea Boriero (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
given
public class Parent {
private Integer id;
private String name;
@OneToMany(fetch = FetchType.EAGER)
private List<Child> children = new ArrayList<>();
public void setChildren(List<Child> children) {
this.children = children;
for ( Iterator<Child> i = children.iterator(); i.hasNext(); ) {
if ( i.next() == null ) {
i.remove();
}
}
}
then the following query
session.createQuery( "select p from Parent p" ).list();
produces 2 queries for to initialize the children collection of the parent instances that
have no children.
(
https://hibernate.atlassian.net/browse/HHH-16184#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16184#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#100216- sha1:7a51a57 )