Skip to content

Commit 0be538a

Browse files
committed
HHH-19394 disable transient reference checking for readonly entities
1 parent 0613466 commit 0be538a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

hibernate-core/src/main/java/org/hibernate/event/internal/AbstractFlushingEventListener.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void checkForTransientReferences(EventSource session, PersistenceContext persist
147147
// into Nullability, instead of abusing the Cascade infrastructure)
148148
for ( Map.Entry<Object, EntityEntry> me : persistenceContext.reentrantSafeEntityEntries() ) {
149149
final EntityEntry entry = me.getValue();
150-
if ( flushable( entry ) ) {
150+
if ( checkable( entry ) ) {
151151
Cascade.cascade(
152152
CascadingActions.CHECK_ON_FLUSH,
153153
CascadePoint.BEFORE_FLUSH,
@@ -167,6 +167,12 @@ private static boolean flushable(EntityEntry entry) {
167167
|| status == Status.READ_ONLY; // debatable, see HHH-19398
168168
}
169169

170+
private static boolean checkable(EntityEntry entry) {
171+
final Status status = entry.getStatus();
172+
return status == Status.MANAGED
173+
|| status == Status.SAVING;
174+
}
175+
170176
private void cascadeOnFlush(EventSource session, EntityPersister persister, Object object, PersistContext anything)
171177
throws HibernateException {
172178
final PersistenceContext persistenceContext = session.getPersistenceContextInternal();

0 commit comments

Comments
 (0)