File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
main/java/org/hibernate/boot/model/internal
test/java/org/hibernate/orm/test/jpa/metadata Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -979,7 +979,10 @@ private static void bindVersionProperty(
979
979
final org .hibernate .mapping .MappedSuperclass superclass =
980
980
getMappedSuperclassOrNull ( declaringClass , inheritanceStatePerClass , context );
981
981
if ( superclass != null ) {
982
- superclass .setDeclaredVersion ( property );
982
+ // Don't overwrite an existing version property
983
+ if ( superclass .getDeclaredVersion () == null ) {
984
+ superclass .setDeclaredVersion ( property );
985
+ }
983
986
}
984
987
else {
985
988
//we know the property is on the actual entity
Original file line number Diff line number Diff line change 29
29
30
30
import org .hibernate .testing .TestForIssue ;
31
31
import org .hibernate .testing .orm .junit .EntityManagerFactoryScope ;
32
+ import org .hibernate .testing .orm .junit .Jira ;
32
33
import org .hibernate .testing .orm .junit .Jpa ;
33
34
import org .hibernate .testing .util .ServiceRegistryUtil ;
34
35
import org .junit .jupiter .api .Test ;
@@ -413,6 +414,17 @@ public void testBackrefAndGenerics(EntityManagerFactoryScope scope) {
413
414
assertEquals (collectionElement , child );
414
415
}
415
416
417
+ @ Test
418
+ @ Jira ("https://hibernate.atlassian.net/browse/HHH-17465" )
419
+ public void testInheritedVersion (EntityManagerFactoryScope scope ) {
420
+ EntityManagerFactory emf = scope .getEntityManagerFactory ();
421
+ assertNotNull (emf .getMetamodel ());
422
+ final EntityType <Cat > entityType = emf .getMetamodel ().entity (Cat .class );
423
+ assertTrue (entityType .hasVersionAttribute ());
424
+ assertTrue (entityType .getSingularAttribute ("version" ).isVersion ());
425
+
426
+ }
427
+
416
428
private void ensureProperMember (Set <?> attributes ) {
417
429
//we do not update the set so we are safe
418
430
@ SuppressWarnings ("unchecked" ) final Set <Attribute <?, ?>> safeAttributes = (Set <Attribute <?, ?>>) attributes ;
You can’t perform that action at this time.
0 commit comments