Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.Status;
import org.hibernate.event.spi.EventSource;
import org.hibernate.event.spi.FlushEntityEvent;
import org.hibernate.event.spi.FlushEntityEventListener;
import org.hibernate.jpa.event.spi.CallbackRegistry;
Expand Down Expand Up @@ -75,14 +76,19 @@ public void checkId(Object object, EntityPersister persister, EntityEntry entry,
if ( entryId != currentId
&& !entry.getStatus().isDeletedOrGone()
&& !persister.getIdentifierType().isEqual( entryId, currentId, session.getFactory() ) ) {
throw new HibernateException( "Identifier of an instance of '" + persister.getEntityName()
+ "' was altered from " + entryId + " to " + currentId );
identifiedAltered( persister, entryId, currentId );
}
}
// else this is a situation where the entity id is assigned by a post-insert
// generator and was saved outside the transaction, forcing it to be delayed
}

// Used by Hibernate Reactive
protected void identifiedAltered(EntityPersister persister, Object entryId, Object currentId) {
throw new HibernateException( "Identifier of an instance of '" + persister.getEntityName()
+ "' was altered from " + entryId + " to " + currentId );
}

private void checkNaturalId(
EntityPersister persister,
Object entity,
Expand Down Expand Up @@ -243,6 +249,13 @@ private boolean scheduleUpdate(final FlushEntityEvent event) {
// we'll use scheduled updates for that.
new Nullability( session, NullabilityCheckType.UPDATE ).checkNullability( values, persister );

addEntityUpdateActionToActionQueue( event, session, entry, values, dirtyProperties, status, persister, entity, nextVersion );

return intercepted;
}

// Used by Hibernate Reactive
protected void addEntityUpdateActionToActionQueue(FlushEntityEvent event, EventSource session, EntityEntry entry, Object[] values, int[] dirtyProperties, Status status, EntityPersister persister, Object entity, Object nextVersion) {
// schedule the update
// note that we intentionally do _not_ pass in currentPersistentState!
session.getActionQueue().addAction(
Expand All @@ -262,8 +275,6 @@ private boolean scheduleUpdate(final FlushEntityEvent event) {
session
)
);

return intercepted;
}

private static int[] getDirtyProperties(FlushEntityEvent event, boolean intercepted) {
Expand Down