Hibernate JPA @NamedAttributeNode Example

@NamedAttributeNode

The @NamedAttributeNode annotation is used to specify each individual attribute node that needs to be fetched by an Entity Graph. A NamedAttributeNode is a member element of a NamedEntityGraph.

Fetch graph example

@Entity(name = "Employee")
@NamedEntityGraph(name = "employee.projects",
attributeNodes = @NamedAttributeNode("projects")
)
Employee employee = entityManager.find(
Employee.class,
userId,
Collections.singletonMap(
"javax.persistence.fetchgraph",
entityManager.getEntityGraph( "employee.projects" )
)
);

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations