HHH-17465 Incorrect metamodel for shared version attribute in @MappedSuperclass
This commit is contained in:
parent
e54a6e15b2
commit
263ef56970
|
@ -979,7 +979,10 @@ public class PropertyBinder {
|
|||
final org.hibernate.mapping.MappedSuperclass superclass =
|
||||
getMappedSuperclassOrNull( declaringClass, inheritanceStatePerClass, context );
|
||||
if ( superclass != null ) {
|
||||
superclass.setDeclaredVersion( property );
|
||||
// Don't overwrite an existing version property
|
||||
if ( superclass.getDeclaredVersion() == null ) {
|
||||
superclass.setDeclaredVersion( property );
|
||||
}
|
||||
}
|
||||
else {
|
||||
//we know the property is on the actual entity
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.Jira;
|
||||
import org.hibernate.testing.orm.junit.Jpa;
|
||||
import org.hibernate.testing.util.ServiceRegistryUtil;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -413,6 +414,17 @@ public class MetadataTest {
|
|||
assertEquals(collectionElement, child);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Jira("https://hibernate.atlassian.net/browse/HHH-17465")
|
||||
public void testInheritedVersion(EntityManagerFactoryScope scope) {
|
||||
EntityManagerFactory emf = scope.getEntityManagerFactory();
|
||||
assertNotNull(emf.getMetamodel());
|
||||
final EntityType<Cat> entityType = emf.getMetamodel().entity(Cat.class);
|
||||
assertTrue(entityType.hasVersionAttribute());
|
||||
assertTrue(entityType.getSingularAttribute("version").isVersion());
|
||||
|
||||
}
|
||||
|
||||
private void ensureProperMember(Set<?> attributes) {
|
||||
//we do not update the set so we are safe
|
||||
@SuppressWarnings("unchecked") final Set<Attribute<?, ?>> safeAttributes = (Set<Attribute<?, ?>>) attributes;
|
||||
|
|
Loading…
Reference in New Issue