Skip to content

Commit 5b11014

Browse files
vladmihalceagbadner
authored andcommitted
HHH-13217 - Don't throw exception if both @MappedSuperclass and @Inheritance are used
Make sure the @Inheritance annotation is ignored when used along with @MappedSuperclass
1 parent f086821 commit 5b11014

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

hibernate-core/src/test/java/org/hibernate/test/inheritance/MappedSuperclassInheritanceTest.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,20 @@
1414
import javax.persistence.MappedSuperclass;
1515

1616
import org.hibernate.cfg.AnnotationBinder;
17+
import org.hibernate.hql.internal.ast.QuerySyntaxException;
1718
import org.hibernate.internal.CoreMessageLogger;
1819
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
1920

2021
import org.hibernate.testing.TestForIssue;
2122
import org.hibernate.testing.logger.LoggerInspectionRule;
2223
import org.hibernate.testing.logger.Triggerable;
24+
import org.hibernate.testing.util.ExceptionUtil;
2325
import org.junit.Rule;
2426
import org.junit.Test;
2527

2628
import org.jboss.logging.Logger;
2729

30+
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
2831
import static org.junit.Assert.assertEquals;
2932
import static org.junit.Assert.assertFalse;
3033
import static org.junit.Assert.assertTrue;
@@ -62,7 +65,18 @@ public void buildEntityManagerFactory() {
6265

6366
@Test
6467
public void test() {
65-
68+
doInJPA( this::entityManagerFactory, entityManager -> {
69+
entityManager.createQuery("from Manager").getResultList();
70+
entityManager.createQuery("from Developer").getResultList();
71+
72+
try {
73+
//Check the @Inheritance annotation was ignored
74+
entityManager.createQuery("from Employee").getResultList();
75+
} catch (Exception expected) {
76+
QuerySyntaxException rootException = (QuerySyntaxException) ExceptionUtil.rootCause(expected);
77+
assertEquals("Employee is not mapped", rootException.getMessage());
78+
}
79+
} );
6680
}
6781

6882
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)

0 commit comments

Comments
 (0)