June 2018
Intermediate to advanced
408 pages
11h 23m
English
Then named entity graph is a new feature, introduced in JPA 2.1. In this approach, we can define a graph of entities that need to be queried from the database. We can define the entity graph on our entity class by using the @NamedEntityGraph annotation.
The following is an example of how to define a graph using @NamedEntityGraph on the entity class:
@Entity@NamedEntityGraph(name="graph.transactions", attributeNodes= @NamedAttributeNode("transactions"))public class Account implements Serializable { private static final long serialVersionUID = 1232821417960547743L; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "account_id", updatable = false, nullable = false) private Long accountId; private String name; ...Read now
Unlock full access