To configure and use an entity graph:
- Add
@NamedEntityGraphs
to the entity bean in question - Reference the name of the entity graph in the
@EntityGraph
annotation on the query in the JPA repository - (Or create a entity graph and load in a graph and set a hint in a criteria query)
- Verify from a test that the number of queries expected are executed
To configure and use a projection:
- Use
ProjectionConfiguration
to configure aProjectionFactory
- Create interfaces that define what properties are in a projection
- Use the factory to create the projection (e.g.
projectionFactory.createProjection(clazz, object)
) - Verify that a test case returns only the those fields from the projection