HHH-7477 : Fix DiscriminatorTest.testDiscriminatorSubclass

This commit is contained in:
Gail Badner 2012-07-26 14:57:49 -07:00
parent d7c4128826
commit d71a2bb6e2
6 changed files with 16 additions and 4 deletions

View File

@ -745,6 +745,7 @@ public class Binder {
try {
// Create new entity binding
entityBinding = createEntityBinding( entitySource, superEntityBinding );
entityBinding.setMutable( entityBinding.getHierarchyDetails().getRootEntityBinding().isMutable() );
bindSecondaryTables( entityBinding, entitySource );
bindUniqueConstraints( entityBinding, entitySource );
bindAttributes( entityBinding, entitySource );
@ -1046,6 +1047,7 @@ public class Binder {
attributeSource.isLazy(),
attributeSource.getNaturalIdMutability(),
createMetaAttributeContext( attributeBindingContainer, attributeSource ),
referencedEntityBinding,
(SingularAttributeBinding) referencedAttributeBinding,
relationalValueBindings
);

View File

@ -131,6 +131,7 @@ public interface AttributeBindingContainer {
* @param includedInOptimisticLocking
* @param lazy
* @param metaAttributeContext
* @param referencedEntityBinding
* @param referencedAttributeBinding
* @param valueBindings
*
@ -143,6 +144,7 @@ public interface AttributeBindingContainer {
boolean lazy,
SingularAttributeBinding.NaturalIdMutability naturalIdMutability,
MetaAttributeContext metaAttributeContext,
EntityBinding referencedEntityBinding,
SingularAttributeBinding referencedAttributeBinding,
List<RelationalValueBinding> valueBindings);

View File

@ -283,6 +283,7 @@ public class CompositeAttributeBinding
boolean lazy,
NaturalIdMutability naturalIdMutability,
MetaAttributeContext metaAttributeContext,
EntityBinding referencedEntityBinding,
SingularAttributeBinding referencedAttributeBinding,
List<RelationalValueBinding> valueBindings) {
final ManyToOneAttributeBinding binding = new ManyToOneAttributeBinding(
@ -293,6 +294,7 @@ public class CompositeAttributeBinding
lazy,
naturalIdMutability,
metaAttributeContext,
referencedEntityBinding,
referencedAttributeBinding,
valueBindings
);

View File

@ -577,6 +577,7 @@ public class EntityBinding implements AttributeBindingContainer {
boolean lazy,
SingularAttributeBinding.NaturalIdMutability naturalIdMutability,
MetaAttributeContext metaAttributeContext,
EntityBinding referencedEntityBinding,
SingularAttributeBinding referencedAttributeBinding,
List<RelationalValueBinding> valueBindings) {
final ManyToOneAttributeBinding binding = new ManyToOneAttributeBinding(
@ -587,6 +588,7 @@ public class EntityBinding implements AttributeBindingContainer {
lazy,
naturalIdMutability,
metaAttributeContext,
referencedEntityBinding,
referencedAttributeBinding,
valueBindings
);

View File

@ -45,6 +45,7 @@ public class ManyToOneAttributeBinding
extends AbstractSingularAttributeBinding
implements SingularAssociationAttributeBinding {
private final EntityBinding referencedEntityBinding;
private final SingularAttributeBinding referencedAttributeBinding;
private final List<RelationalValueBinding> relationalValueBindings;
@ -60,6 +61,7 @@ public class ManyToOneAttributeBinding
boolean lazy,
NaturalIdMutability naturalIdMutability,
MetaAttributeContext metaAttributeContext,
EntityBinding referencedEntityBinding,
SingularAttributeBinding referencedAttributeBinding,
List<RelationalValueBinding> relationalValueBindings) {
super(
@ -72,6 +74,9 @@ public class ManyToOneAttributeBinding
metaAttributeContext
);
if ( referencedEntityBinding == null ) {
throw new IllegalArgumentException( "referencedEntityBinding must be non-null." );
}
if ( referencedAttributeBinding == null ) {
throw new IllegalArgumentException( "referencedAttributeBinding must be non-null." );
}
@ -79,6 +84,7 @@ public class ManyToOneAttributeBinding
throw new AssertionFailure( "Illegal attempt to resolve many-to-one reference based on non-entity attribute" );
}
this.referencedEntityBinding = referencedEntityBinding;
this.referencedAttributeBinding = referencedAttributeBinding;
this.relationalValueBindings = Collections.unmodifiableList( relationalValueBindings );
}
@ -106,7 +112,7 @@ public class ManyToOneAttributeBinding
@Override
public final String getReferencedEntityName() {
return getReferencedEntityBinding().getEntity().getName();
return referencedEntityBinding.getEntity().getName();
}
@Override
@ -175,7 +181,7 @@ public class ManyToOneAttributeBinding
@Override
public final EntityBinding getReferencedEntityBinding() {
return referencedAttributeBinding.getContainer().seekEntityBinding();
return referencedEntityBinding;
}
@Override

View File

@ -33,7 +33,6 @@ import org.hibernate.Transaction;
import org.hibernate.criterion.Property;
import org.hibernate.criterion.Restrictions;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
@ -53,7 +52,6 @@ public class DiscriminatorTest extends BaseCoreFunctionalTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testDiscriminatorSubclass() {
Session s = openSession();
Transaction t = s.beginTransaction();