@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;
}