From 9fe28d57c0e1e91ef5a0aba7936d99ba581b5b95 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Wed, 10 Sep 2025 16:57:23 +0200 Subject: [PATCH] Fixup problem after #10856 encapsulate EntityMetamodel within AbstractEntityPersister --- .../persister/entity/AbstractEntityPersister.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java index e82437d18bb7..dff8541a6b43 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java @@ -4646,7 +4646,7 @@ private void prepareMappings(MappingModelCreationProcess creationProcess) { creationProcess.getCreationContext().getBootModel() .getEntityBinding( getEntityName() ); initializeSpecialAttributeMappings( creationProcess, persistentClass ); - versionGenerator = createVersionGenerator( this, versionMapping ); + versionGenerator = createVersionGenerator( super.getVersionGenerator(), versionMapping ); buildDeclaredAttributeMappings( creationProcess, persistentClass ); getAttributeMappings(); initializeNaturalIdMapping( creationProcess, persistentClass ); @@ -4705,15 +4705,15 @@ private void inheritSupertypeSpecialAttributeMappings() { } } - private static BeforeExecutionGenerator createVersionGenerator - (EntityMetamodel currentEntityMetamodel, EntityVersionMapping versionMapping) { - if ( currentEntityMetamodel.isVersioned() ) { - final var generator = currentEntityMetamodel.getVersionGenerator(); + private static @Nullable BeforeExecutionGenerator createVersionGenerator( + @Nullable BeforeExecutionGenerator configuredGenerator, + @Nullable EntityVersionMapping versionMapping) { + if ( versionMapping != null ) { // need to do this here because EntityMetamodel doesn't have the EntityVersionMapping :-( - return generator == null ? new VersionGeneration( versionMapping ) : generator; + return configuredGenerator == null ? new VersionGeneration( versionMapping ) : configuredGenerator; } else { - return null; + return configuredGenerator; } }