diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityBinding.java b/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityBinding.java index 3d4e486e63..5370101cf5 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityBinding.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityBinding.java @@ -30,6 +30,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.hibernate.AssertionFailure; import org.hibernate.MappingException; import org.hibernate.engine.internal.Versioning; import org.hibernate.internal.util.ReflectHelper; @@ -49,6 +50,7 @@ import org.hibernate.metamodel.source.util.MappingHelper; * Provides the link between the domain and the relational model for an entity. * * @author Steve Ebersole + * @author Hardy Ferentschik */ public class EntityBinding { private final EntityIdentifier entityIdentifier = new EntityIdentifier( this ); @@ -247,9 +249,9 @@ public class EntityBinding { public SimpleAttributeBinding makeEntityDiscriminatorBinding(String name) { if ( entityDiscriminator != null ) { - // TODO: LOG this!!! + throw new AssertionFailure( "Creation of entity discriminator was called more than once" ); } - entityDiscriminator = new EntityDiscriminator( this ); + entityDiscriminator = new EntityDiscriminator(); entityDiscriminator.setValueBinding( makeSimpleAttributeBinding( name, true, false ) ); return entityDiscriminator.getValueBinding(); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityDiscriminator.java b/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityDiscriminator.java index d35ad26c02..39e4cb2131 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityDiscriminator.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityDiscriminator.java @@ -24,18 +24,16 @@ package org.hibernate.metamodel.binding; /** - * TODO : javadoc + * Binding of the discriminator in a entity hierarchy * * @author Steve Ebersole */ public class EntityDiscriminator { - private final EntityBinding entityBinding; private SimpleAttributeBinding valueBinding; private boolean forced; private boolean inserted = true; - public EntityDiscriminator(EntityBinding entityBinding) { - this.entityBinding = entityBinding; + public EntityDiscriminator() { } public SimpleAttributeBinding getValueBinding() { @@ -61,4 +59,15 @@ public class EntityDiscriminator { public void setInserted(boolean inserted) { this.inserted = inserted; } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append( "EntityDiscriminator" ); + sb.append( "{valueBinding=" ).append( valueBinding ); + sb.append( ", forced=" ).append( forced ); + sb.append( ", inserted=" ).append( inserted ); + sb.append( '}' ); + return sb.toString(); + } }