2222import org .hibernate .engine .spi .SessionFactoryImplementor ;
2323import org .hibernate .engine .spi .SessionImplementor ;
2424import org .hibernate .engine .spi .Status ;
25+ import org .hibernate .event .spi .EventSource ;
2526import org .hibernate .event .spi .FlushEntityEvent ;
2627import org .hibernate .event .spi .FlushEntityEventListener ;
2728import org .hibernate .jpa .event .spi .CallbackRegistry ;
@@ -75,14 +76,19 @@ public void checkId(Object object, EntityPersister persister, EntityEntry entry,
7576 if ( entryId != currentId
7677 && !entry .getStatus ().isDeletedOrGone ()
7778 && !persister .getIdentifierType ().isEqual ( entryId , currentId , session .getFactory () ) ) {
78- throw new HibernateException ( "Identifier of an instance of '" + persister .getEntityName ()
79- + "' was altered from " + entryId + " to " + currentId );
79+ identifiedAltered ( persister , entryId , currentId );
8080 }
8181 }
8282 // else this is a situation where the entity id is assigned by a post-insert
8383 // generator and was saved outside the transaction, forcing it to be delayed
8484 }
8585
86+ // Used by Hibernate Reactive
87+ protected void identifiedAltered (EntityPersister persister , Object entryId , Object currentId ) {
88+ throw new HibernateException ( "Identifier of an instance of '" + persister .getEntityName ()
89+ + "' was altered from " + entryId + " to " + currentId );
90+ }
91+
8692 private void checkNaturalId (
8793 EntityPersister persister ,
8894 Object entity ,
@@ -243,6 +249,13 @@ private boolean scheduleUpdate(final FlushEntityEvent event) {
243249 // we'll use scheduled updates for that.
244250 new Nullability ( session , NullabilityCheckType .UPDATE ).checkNullability ( values , persister );
245251
252+ addEntityUpdateActionToActionQueue ( event , session , entry , values , dirtyProperties , status , persister , entity , nextVersion );
253+
254+ return intercepted ;
255+ }
256+
257+ // Used by Hibernate Reactive
258+ protected void addEntityUpdateActionToActionQueue (FlushEntityEvent event , EventSource session , EntityEntry entry , Object [] values , int [] dirtyProperties , Status status , EntityPersister persister , Object entity , Object nextVersion ) {
246259 // schedule the update
247260 // note that we intentionally do _not_ pass in currentPersistentState!
248261 session .getActionQueue ().addAction (
@@ -262,8 +275,6 @@ private boolean scheduleUpdate(final FlushEntityEvent event) {
262275 session
263276 )
264277 );
265-
266- return intercepted ;
267278 }
268279
269280 private static int [] getDirtyProperties (FlushEntityEvent event , boolean intercepted ) {
0 commit comments