HHH-8935 MappedSuperclass can extend an Entity
This commit is contained in:
parent
d8b669b951
commit
a2971e4f75
|
@ -267,7 +267,7 @@ public class EntityHierarchyBuilder {
|
|||
|
||||
for ( ClassInfo subClassInfo : subClasses ) {
|
||||
if ( !isEntityClass( subClassInfo ) ) {
|
||||
MappingAssertion.assertSubEntityIsNotEmbeddableNorMappedSuperclass( subClassInfo );
|
||||
MappingAssertion.assertSubEntityIsNotEmbeddable( subClassInfo );
|
||||
continue;
|
||||
}
|
||||
addSubClassToSubclassMap( classInfo.name(), subClassInfo, classToDirectSubclassMap );
|
||||
|
|
|
@ -69,18 +69,14 @@ public class MappingAssertion {
|
|||
|
||||
|
||||
/**
|
||||
* Check if the sub-entity has {@link javax.persistence.Embeddable @Embeddable} or {@link javax.persistence.MappedSuperclass @MappedSuperclass}.
|
||||
*
|
||||
* From the JPA Spec, a sub entity class can not has such annotation.
|
||||
* Check if the sub-entity has {@link javax.persistence.Embeddable @Embeddable}. From the JPA Spec,
|
||||
* a sub entity class can not has such annotation.
|
||||
*
|
||||
* @param subClassInfo The sub entity {@link ClassInfo class}.
|
||||
*/
|
||||
static void assertSubEntityIsNotEmbeddableNorMappedSuperclass(ClassInfo subClassInfo) {
|
||||
static void assertSubEntityIsNotEmbeddable(ClassInfo subClassInfo) {
|
||||
if ( JandexHelper.containsSingleAnnotation( subClassInfo, JPADotNames.EMBEDDABLE ) ) {
|
||||
throw new AnnotationException( "An embeddable cannot extend an entity: " + subClassInfo );
|
||||
}
|
||||
if ( JandexHelper.containsSingleAnnotation( subClassInfo, JPADotNames.MAPPED_SUPERCLASS ) ) {
|
||||
throw new AnnotationException( "A mapped superclass cannot extend an entity: " + subClassInfo );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,24 +23,23 @@
|
|||
*/
|
||||
package org.hibernate.test.annotations.polymorphism;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
* @author Brett Meyer
|
||||
*/
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public class PolymorphismTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
@Test
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public void testPolymorphism() throws Exception {
|
||||
Car car = new Car();
|
||||
car.setModel( "SUV" );
|
||||
|
|
Loading…
Reference in New Issue