HHH-7503 Adding check for single table inheritance in which case the @NotNull constraint is not applied

This commit is contained in:
Hardy Ferentschik 2012-08-23 17:55:55 +02:00
parent 88d75b541d
commit d541b9abff
1 changed files with 10 additions and 0 deletions

View File

@ -33,6 +33,8 @@ import org.hibernate.mapping.Column;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.SingleTableSubclass;
import org.hibernate.metamodel.spi.binding.AttributeBinding;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.InheritanceType;
/**
* @author Hardy Ferentschik
@ -65,6 +67,14 @@ public class NotNullSchemaConstraint implements SchemaConstraint {
return false;
}
EntityBinding entityBinding = (EntityBinding) attributeBinding.getContainer();
InheritanceType inheritanceType = entityBinding.getHierarchyDetails().getInheritanceType();
// properties of a single table inheritance configuration should not be forced to null
if(InheritanceType.SINGLE_TABLE.equals( inheritanceType )) {
return false;
}
org.hibernate.metamodel.spi.relational.Column column = SchemaModificationHelper.getSingleColumn( attributeBinding );
if ( column == null ) {
return false;