[JIRA] (HHH-15607) @NamedEntityGraph is not working when try to load Basic attribute with OneToMany relation.
by Khurelkhuyag M. (JIRA)
Khurelkhuyag M. ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiOWQ0OGE3OWVi... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-15607?atlOrigin=eyJpIjoiOWQ0OG... ) HHH-15607 ( https://hibernate.atlassian.net/browse/HHH-15607?atlOrigin=eyJpIjoiOWQ0OG... ) @NamedEntityGraph is not working when try to load Basic attribute with OneToMany relation. ( https://hibernate.atlassian.net/browse/HHH-15607?atlOrigin=eyJpIjoiOWQ0OG... )
Change By: Khurelkhuyag M. ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
For demonstration purposes, I created the below example. If I try to use a named entity graph with “{{LazyEntity.stringOnly}}“, or “{{LazyEntity.childrenOnly}}“. It works fine. But I try to use “{{LazyEntity.stringAndChildren}}“ it only loads the “children” not “string” property.
I also attached an example project.
{code:java}@Entity
@Table(name = "lazy")
@NamedEntityGraph(
name = "LazyEntity.stringOnly",
attributeNodes = {
@NamedAttributeNode("string"),
}
)
@NamedEntityGraph(
name = "LazyEntity.childrenOnly",
attributeNodes = {
@NamedAttributeNode("children"),
}
)
@NamedEntityGraph(
name = "LazyEntity.stringAndChildren",
attributeNodes = {
@NamedAttributeNode("string"),
@NamedAttributeNode("children"),
}
)
public class LazyEntity {
@Id
private Long id;
@Basic(fetch = FetchType.LAZY)
private String string;
@OrderBy("createdAt DESC")
@OneToMany(mappedBy = "parent")
private List<LazyChild> children;
// getter setters ommited
}{code}
If I run the example project with {{mvn compile exec:java}} command, This output will display. it says when the named entity graph “{{LazyEntity.stringAndChildren}}“ not working correctly.
{noformat}LazyEntity.stringAndChildren
string: false
children: true
LazyEntity.stringOnly
string: true
children: false
LazyEntity.childrenOnly
string: false
children: true{noformat}
( https://hibernate.atlassian.net/browse/HHH-15607#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-15607#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#100209- sha1:13f5f09 )
2 years, 2 months
[JIRA] (HHH-15607) @NamedEntityGraph is not working when try to load Basic attribute with OneToMany relation.
by Хүрэлхуяг М. (JIRA)
Хүрэлхуяг М. ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNjIyMWU5MjE3... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-15607?atlOrigin=eyJpIjoiNjIyMW... ) HHH-15607 ( https://hibernate.atlassian.net/browse/HHH-15607?atlOrigin=eyJpIjoiNjIyMW... ) @NamedEntityGraph is not working when try to load Basic attribute with OneToMany relation. ( https://hibernate.atlassian.net/browse/HHH-15607?atlOrigin=eyJpIjoiNjIyMW... )
Issue Type: Bug Affects Versions: 6.1.4 Assignee: Unassigned Attachments: proof-hibernate-lazy-not-working.zip Components: hibernate-core, hibernate-enhance-maven-plugin Created: 17/Oct/2022 09:20 AM Environment: Maven: apache-maven-3.8.3
Java version: 17.0.4, vendor: Private Build, runtime: /usr/lib/jvm/java-17-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.15.0-50-generic", arch: "amd64", family: "unix"
Priority: Minor Reporter: Хүрэлхуяг М. ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
@Entity
@Table(name = "lazy" )
@NamedEntityGraph(
name = "LazyEntity.stringOnly" ,
attributeNodes = {
@NamedAttributeNode( "string" ),
}
)
@NamedEntityGraph(
name = "LazyEntity.childrenOnly" ,
attributeNodes = {
@NamedAttributeNode( "children" ),
}
)
@NamedEntityGraph(
name = "LazyEntity.stringAndChildren" ,
attributeNodes = {
@NamedAttributeNode( "string" ),
@NamedAttributeNode( "children" ),
}
)
public class LazyEntity {
@Id
private Long id;
@Basic(fetch = FetchType.LAZY)
private String string;
@OrderBy( "createdAt DESC" )
@OneToMany(mappedBy = "parent" )
private List<LazyChild> children;
// getter setters ommited
}
( https://hibernate.atlassian.net/browse/HHH-15607#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-15607#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#100209- sha1:13f5f09 )
2 years, 2 months