HHH-18734 detect erroneous/unsupported use of @SQLRestriction on subclass entity
This commit is contained in:
parent
6913234e0e
commit
69f8b9af2d
|
@ -1310,10 +1310,8 @@ public class EntityBinder {
|
|||
if ( persistentClass instanceof RootClass ) {
|
||||
bindRootEntity();
|
||||
}
|
||||
else if ( !isMutable() ) {
|
||||
throw new AnnotationException("Entity class '" + annotatedClass.getName()
|
||||
+ "' is annotated '@Immutable' but it is a subclass in an entity inheritance hierarchy"
|
||||
+ " (only root classes may declare mutability)");
|
||||
else {
|
||||
checkSubclassEntity();
|
||||
}
|
||||
|
||||
ensureNoMutabilityPlan();
|
||||
|
@ -1323,6 +1321,19 @@ public class EntityBinder {
|
|||
processNamedEntityGraphs();
|
||||
}
|
||||
|
||||
private void checkSubclassEntity() {
|
||||
if ( !isMutable() ) {
|
||||
throw new AnnotationException( "Entity class '" + annotatedClass.getName()
|
||||
+ "' is annotated '@Immutable' but it is a subclass in an entity inheritance hierarchy"
|
||||
+ " (only a root class may declare its mutability)" );
|
||||
}
|
||||
if ( isNotEmpty( where ) ) {
|
||||
throw new AnnotationException( "Entity class '" + annotatedClass.getName()
|
||||
+ "' specifies an '@SQLRestriction' but it is a subclass in an entity inheritance hierarchy"
|
||||
+ " (only a root class may be specify a restriction)" );
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureNoMutabilityPlan() {
|
||||
if ( annotatedClass.hasAnnotationUsage( Mutability.class, getSourceModelContext() ) ) {
|
||||
throw new MappingException( "@Mutability is not allowed on entity" );
|
||||
|
|
Loading…
Reference in New Issue