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=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100209- sha1:13f5f09 )