Hi,
I have two JPA entities that look like this:
Code:
@Entity
@Table
@NamedEntityGraphs(value = {
@NamedEntityGraph(name = "User.findByLogin",
attributeNodes = {
@NamedAttributeNode(value = "profile")})
})
public class User implements Serializable{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id = 0;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn
private Profile profile;
// Getters and setters removed
}
@Entity
@Table
public class Profile implements Serializable{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id = 0;
@Column
private String name;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn
private User lastModifier;
// Getters and setters removed
}
When I a query one user with the entitygraph "User.findByLogin", the profile attribute is eagerly loaded as expected.
But my issue is that profile.lastModifier is also eagerly loaded.
Why is the Profile object fully loaded? Shouldn't it respect the default graph and then lazy load the lastModifier attribute?