You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At present I do the following to reload an entity such that all the fields in the entity graph provided are loaded
entityManager.detach(entity);
final var entityType = entityManager.getMetamodel().entity(entity.getClass());
final var entityGraph = entityManager.getEntityGraph(entityType.getName());
return (T)
entityManager.find(
entity.getClass(),
entity.getId(),
Map.of(
"jakarta.persistence.loadgraph", // or "jakarta.persistence.fetchgraph"
entityGraph,
"jakarta.persistence.cache_retrieve_mode",
CacheRetrieveMode.BYPASS));
It would be cleaner I think if I can simply do
final var entityType = entityManager.getMetamodel().entity(entity.getClass());
final var entityGraph = entityManager.getEntityGraph(entityType.getName());
entityManager.refresh(entity,
Map.of(
"jakarta.persistence.loadgraph", // or "jakarta.persistence.fetchgraph"
entityGraph));
// and no cache retrieve mode
To reload the entity with the graph that was provided.
The text was updated successfully, but these errors were encountered:
At present I do the following to reload an entity such that all the fields in the entity graph provided are loaded
It would be cleaner I think if I can simply do
To reload the entity with the graph that was provided.
The text was updated successfully, but these errors were encountered: