detect use of @DiscriminatorOptions(force=true) on JOINED with no @DiscriminatorColumn

This commit is contained in:
Gavin 2022-12-25 03:23:03 +01:00 committed by Gavin King
parent 014847f41b
commit 5f0b27fb6a
1 changed files with 9 additions and 3 deletions

View File

@ -674,7 +674,13 @@ public class EntityBinder {
// the class we're processing is the root of the hierarchy, so
// let's see if we had a discriminator column (it's perfectly
// valid for joined inheritance to not have a discriminator)
if ( discriminatorColumn != null ) {
if ( discriminatorColumn == null ) {
if ( isForceDiscriminatorInSelects() ) {
throw new AnnotationException( "Entity '" + rootClass.getEntityName()
+ "' with 'JOINED' inheritance is annotated '@DiscriminatorOptions(force=true)' but has no discriminator column" );
}
}
else {
// we do have a discriminator column
if ( state.hasSiblings() || !discriminatorColumn.isImplicit() ) {
bindDiscriminatorColumnToRootPersistentClass( rootClass, discriminatorColumn, holder );