Skip to content

Commit c42a5dd

Browse files
committed
[#2924] DefaultReactiveRefreshEventListener: introduced DetachedObjectException
1 parent 2442d89 commit c42a5dd

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/event/impl/DefaultReactiveRefreshEventListener.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import java.util.concurrent.CompletableFuture;
99
import java.util.concurrent.CompletionStage;
1010

11+
import org.hibernate.DetachedObjectException;
1112
import org.hibernate.HibernateException;
1213
import org.hibernate.LockMode;
1314
import org.hibernate.LockOptions;
14-
import org.hibernate.PersistentObjectException;
1515
import org.hibernate.UnresolvableObjectException;
1616
import org.hibernate.cache.spi.access.CollectionDataAccess;
1717
import org.hibernate.cache.spi.access.EntityDataAccess;
@@ -110,21 +110,7 @@ private CompletionStage<Void> reactiveOnRefresh(RefreshEvent event, RefreshConte
110110
final EntityPersister persister;
111111
final Object id;
112112
if ( entry == null ) {
113-
//refresh() does not pass an entityName
114-
persister = source.getEntityPersister( event.getEntityName(), entity );
115-
id = persister.getIdentifier( entity, event.getSession() );
116-
if ( LOG.isTraceEnabled() ) {
117-
LOG.tracev(
118-
"Refreshing transient {0}",
119-
infoString( persister, id, source.getFactory() )
120-
);
121-
}
122-
if ( persistenceContext.getEntry( source.generateEntityKey( id, persister ) ) != null ) {
123-
throw new PersistentObjectException(
124-
"attempted to refresh transient instance when persistent instance was already associated with the session: "
125-
+ infoString( persister, id, source.getFactory() )
126-
);
127-
}
113+
throw new DetachedObjectException( "Given entity is not associated with the persistence context" );
128114
}
129115
else {
130116
if ( LOG.isTraceEnabled() ) {

0 commit comments

Comments
 (0)