Skip to content

Commit 9ff14a3

Browse files
committed
HHH-13147 - Fix DelayedPostIdentifierInsert when second-level cache enabled.
1 parent 6d5dd25 commit 9ff14a3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4164,6 +4164,12 @@ private void resolveIdentityInsertDelayable() {
41644164
canIdentityInsertBeDelayed = true;
41654165

41664166
if ( getEntityMetamodel().getIdentifierProperty().isIdentifierAssignedByInsert() ) {
4167+
// if the persister writes the entity to the second-level cache; we cannot delay.
4168+
if ( canWriteToCache ) {
4169+
canIdentityInsertBeDelayed = false;
4170+
return;
4171+
}
4172+
41674173
// if the persister's identifier is assigned by insert, we need to see if we must force non-delay mode.
41684174
for ( NonIdentifierAttribute attribute : getEntityMetamodel().getProperties() ) {
41694175
if ( isTypeSelfReferencing( attribute.getType() ) ) {

0 commit comments

Comments
 (0)