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
This commit is contained in:
Vlad Mihalcea 2019-02-28 08:29:40 +02:00 committed by gbadner
parent f086821abd
commit 5b11014c7c
1 changed files with 14 additions and 0 deletions

View File

@ -14,17 +14,20 @@ import javax.persistence.InheritanceType;
import javax.persistence.MappedSuperclass;
import org.hibernate.cfg.AnnotationBinder;
import org.hibernate.hql.internal.ast.QuerySyntaxException;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.logger.LoggerInspectionRule;
import org.hibernate.testing.logger.Triggerable;
import org.hibernate.testing.util.ExceptionUtil;
import org.junit.Rule;
import org.junit.Test;
import org.jboss.logging.Logger;
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@ -62,7 +65,18 @@ public class MappedSuperclassInheritanceTest extends BaseEntityManagerFunctional
@Test
public void test() {
doInJPA( this::entityManagerFactory, entityManager -> {
entityManager.createQuery("from Manager").getResultList();
entityManager.createQuery("from Developer").getResultList();
try {
//Check the @Inheritance annotation was ignored
entityManager.createQuery("from Employee").getResultList();
} catch (Exception expected) {
QuerySyntaxException rootException = (QuerySyntaxException) ExceptionUtil.rootCause(expected);
assertEquals("Employee is not mapped", rootException.getMessage());
}
} );
}
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)