Hibernate JPA @NamedEntityGraph Example

@NamedEntityGraph

The @NamedEntityGraph annotation is used to specify an Entity Graph that can be used by an entity query to override the default fetch plan. NamedEntityGraph Used to specify the path and boundaries for a find operation or query.

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

I get wrong characters when retreiving the message body of an email using TIdIMAP4.UIDRetrieveTextPeek2()

How to drop the all the 1's in a correlation matrix

Today Walkin 14th-Sept