HHH-6290 : Add EntityBinding.isRoot()
This commit is contained in:
parent
b84ec25b63
commit
834fa2140f
|
@ -56,6 +56,8 @@ import org.hibernate.metamodel.source.hbm.util.MappingHelper;
|
|||
*/
|
||||
public class EntityBinding {
|
||||
private final EntityIdentifier entityIdentifier = new EntityIdentifier( this );
|
||||
private final boolean isRoot;
|
||||
|
||||
private InheritanceType entityInheritanceType;
|
||||
private EntityDiscriminator entityDiscriminator;
|
||||
private SimpleAttributeBinding versionBinding;
|
||||
|
@ -94,6 +96,10 @@ public class EntityBinding {
|
|||
|
||||
private List<String> synchronizedTableNames;
|
||||
|
||||
public EntityBinding(boolean isRoot) {
|
||||
this.isRoot = isRoot;
|
||||
}
|
||||
|
||||
// TODO: change to intialize from Doimain
|
||||
public void fromHbmXml(MappingDefaults defaults, XMLClass entityClazz, Entity entity) {
|
||||
this.entity = entity;
|
||||
|
@ -175,6 +181,10 @@ public class EntityBinding {
|
|||
isAbstract = entityClazz.isAbstract();
|
||||
}
|
||||
|
||||
public boolean isRoot() {
|
||||
return isRoot;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class EntityBinder {
|
|||
}
|
||||
|
||||
public void bind() {
|
||||
EntityBinding entityBinding = new EntityBinding();
|
||||
EntityBinding entityBinding = new EntityBinding( configuredClass.isRoot() );
|
||||
|
||||
bindJpaEntityAnnotation( entityBinding );
|
||||
bindHibernateEntityAnnotation( entityBinding ); // optional hibernate specific @org.hibernate.annotations.Entity
|
||||
|
|
|
@ -60,7 +60,7 @@ class RootEntityBinder extends AbstractEntityBinder {
|
|||
throw new MappingException( "Unable to determine entity name" );
|
||||
}
|
||||
|
||||
EntityBinding entityBinding = new EntityBinding();
|
||||
EntityBinding entityBinding = new EntityBinding( true );
|
||||
basicEntityBinding( xmlClazz, entityBinding, null );
|
||||
basicTableBinding( xmlClazz, entityBinding );
|
||||
|
||||
|
|
|
@ -123,6 +123,7 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
|||
assertNotNull( entityBinding );
|
||||
assertNotNull( entityBinding.getEntityIdentifier() );
|
||||
assertNotNull( entityBinding.getEntityIdentifier().getValueBinding() );
|
||||
assertTrue( entityBinding.isRoot() );
|
||||
|
||||
AttributeBinding idAttributeBinding = entityBinding.getAttributeBinding( "id" );
|
||||
assertNotNull( idAttributeBinding );
|
||||
|
|
|
@ -52,7 +52,7 @@ public class SimpleValueBindingTests extends BaseUnitTestCase {
|
|||
public void testBasicMiddleOutBuilding() {
|
||||
Table table = new Table( new Schema( null, null ), "the_table" );
|
||||
Entity entity = new Entity( "TheEntity", null );
|
||||
EntityBinding entityBinding = new EntityBinding();
|
||||
EntityBinding entityBinding = new EntityBinding( true );
|
||||
entityBinding.setEntity( entity );
|
||||
entityBinding.setBaseTable( table );
|
||||
|
||||
|
|
|
@ -32,7 +32,9 @@ import org.junit.Test;
|
|||
import org.hibernate.metamodel.binding.EntityBinding;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Hardy Ferentschik
|
||||
|
@ -42,6 +44,7 @@ public class InheritanceTypeTest extends BaseAnnotationBindingTestCase {
|
|||
public void testNoInheritance() {
|
||||
buildMetadataSources( SingleEntity.class );
|
||||
EntityBinding entityBinding = getEntityBinding( SingleEntity.class );
|
||||
assertTrue( entityBinding.isRoot() );
|
||||
assertNull( entityBinding.getEntityDiscriminator() );
|
||||
}
|
||||
|
||||
|
@ -51,6 +54,7 @@ public class InheritanceTypeTest extends BaseAnnotationBindingTestCase {
|
|||
RootOfSingleTableInheritance.class, SubclassOfSingleTableInheritance.class
|
||||
);
|
||||
EntityBinding entityBinding = getEntityBinding( SubclassOfSingleTableInheritance.class );
|
||||
assertFalse( entityBinding.isRoot() );
|
||||
assertEquals( "Wrong discriminator value", "foo", entityBinding.getDiscriminatorValue() );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue