Skip to content

Commit

Permalink
add overload of refresh() accepting an EntityGraph
Browse files Browse the repository at this point in the history
see issue jakartaee#437

Signed-off-by: Gavin King <[email protected]>
  • Loading branch information
gavinking committed Sep 20, 2024
1 parent 1aac75c commit 08bf9b9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions api/src/main/java/jakarta/persistence/EntityManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,26 @@ void refresh(Object entity, LockModeType lockMode,
void refresh(Object entity,
RefreshOption... options);

/**
* Refresh the state of the given managed entity instance from the
* database, along with all associated entities reachable by
* following the given {@link EntityGraph}, overwriting changes
* made to the entity, if any. This operation does not cascade to
* associations marked {@link CascadeType#REFRESH cascade=REFRESH}
* unless they are included in the given entity graph.
* @param entity a managed entity instance
* @throws IllegalArgumentException if the instance is not an entity
* or if the entity is not managed
* @throws TransactionRequiredException if there is no
* transaction when invoked on a container-managed
* entity manager of type
* {@link PersistenceContextType#TRANSACTION}
* @throws EntityNotFoundException if the entity no longer exists in
* the database
* @since 4.0
*/
<T> void refresh(T entity, EntityGraph<T> entityGraph);

/**
* Clear the persistence context, causing all managed entities to
* become detached. Changes made to entities that have not already
Expand Down

0 comments on commit 08bf9b9

Please sign in to comment.