HHH-7679 Source implementations should not determine default

discriminator match value
This commit is contained in:
brmeyer 2012-10-12 16:22:51 -04:00
parent 0b4dfcb435
commit 5fb7f4b343
3 changed files with 18 additions and 16 deletions

View File

@ -675,7 +675,13 @@ public class Binder {
final EntityDiscriminator discriminator =
new EntityDiscriminator( value, discriminatorSource.isInserted(), discriminatorSource.isForced() );
rootEntityBinding.getHierarchyDetails().setEntityDiscriminator( discriminator );
rootEntityBinding.setDiscriminatorMatchValue( rootEntitySource.getDiscriminatorMatchValue() );
final String discriminatorValue = rootEntitySource.getDiscriminatorMatchValue();
if ( discriminatorValue != null ) {
rootEntityBinding.setDiscriminatorMatchValue( discriminatorValue );
}
else {
rootEntityBinding.setDiscriminatorMatchValue( rootEntitySource.getEntityName() );
}
// Configure discriminator hibernate type
final String typeName =
discriminatorSource.getExplicitHibernateTypeName() != null
@ -1777,6 +1783,9 @@ public class Binder {
if ( discriminatorValue != null ) {
entityBinding.setDiscriminatorMatchValue( discriminatorValue );
}
else {
entityBinding.setDiscriminatorMatchValue( entitySource.getEntityName() );
}
}
else {
bindPrimaryTable( entityBinding, entitySource );

View File

@ -235,11 +235,7 @@ public class EntityClass extends ConfiguredClass {
}
public String getDiscriminatorMatchValue() {
if ( discriminatorMatchValue == null) {
return getClassInfo().name().toString();
} else {
return discriminatorMatchValue;
}
return discriminatorMatchValue;
}
public List<JpaCallbackSource> getJpaCallbacks() {

View File

@ -23,9 +23,13 @@
*/
package org.hibernate.metamodel.internal.source;
import java.util.Iterator;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import java.util.Iterator;
import org.hibernate.EntityMode;
import org.hibernate.boot.registry.StandardServiceRegistry;
@ -47,14 +51,8 @@ import org.hibernate.metamodel.spi.source.SimpleIdentifierSource;
import org.hibernate.metamodel.spi.source.SingularAttributeSource;
import org.hibernate.metamodel.spi.source.TableSource;
import org.hibernate.metamodel.spi.source.TableSpecificationSource;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
* @author Steve Ebersole
@ -63,7 +61,6 @@ public class AssertSourcesTest extends BaseUnitTestCase {
final StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().build() ;
@Test
@FailureExpectedWithNewMetamodel( jiraKey = "HHH-7679" )
public void testUserEntitySources() {
MetadataSources hbm = new MetadataSources( serviceRegistry );
hbm.addResource( getClass().getPackage().getName().replace( '.', '/' ) + "/User.hbm.xml" );