O'Reilly logo

Hands-On High Performance with Spring 5 by Dinesh Radadiya, Prashant Goswami, Pritesh Shah, Subhash Shah, Chintan Mehta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Named entity graph

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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required