HHH-7762 Discriminators broken on abstract superclass with no

@DiscriminatorValue
This commit is contained in:
brmeyer 2012-12-04 11:47:21 -05:00
parent 51e7504a50
commit 4af03102e4
2 changed files with 12 additions and 12 deletions

View File

@ -25,6 +25,7 @@ package org.hibernate.metamodel.internal;
import static org.hibernate.engine.spi.SyntheticAttributeHelper.SYNTHETIC_COMPOSITE_ID_ATTRIBUTE_NAME;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
@ -75,9 +76,9 @@ import org.hibernate.metamodel.spi.binding.HibernateTypeDescriptor;
import org.hibernate.metamodel.spi.binding.IdGenerator;
import org.hibernate.metamodel.spi.binding.IndexedPluralAttributeBinding;
import org.hibernate.metamodel.spi.binding.InheritanceType;
import org.hibernate.metamodel.spi.binding.ManyToManyPluralAttributeElementBinding;
import org.hibernate.metamodel.spi.binding.ManyToOneAttributeBinding;
import org.hibernate.metamodel.spi.binding.MetaAttribute;
import org.hibernate.metamodel.spi.binding.ManyToManyPluralAttributeElementBinding;
import org.hibernate.metamodel.spi.binding.OneToManyPluralAttributeElementBinding;
import org.hibernate.metamodel.spi.binding.OneToOneAttributeBinding;
import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
@ -802,7 +803,9 @@ public class Binder {
if ( discriminatorValue != null ) {
rootEntityBinding.setDiscriminatorMatchValue( discriminatorValue );
}
else {
else if ( !Modifier.isAbstract( bindingContext().locateClassByName( rootEntitySource.getEntityName() ).getModifiers() ) ) {
// Use the class name as a default if no dscriminator value.
// However, skip abstract classes -- obviously no discriminators there.
rootEntityBinding.setDiscriminatorMatchValue( rootEntitySource.getEntityName() );
}
// Configure discriminator hibernate type

View File

@ -23,9 +23,13 @@
*/
package org.hibernate.test.annotations.inheritance;
import java.util.List;
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.List;
import org.hibernate.Query;
import org.hibernate.Session;
@ -37,19 +41,12 @@ import org.hibernate.test.annotations.inheritance.singletable.Funk;
import org.hibernate.test.annotations.inheritance.singletable.Music;
import org.hibernate.test.annotations.inheritance.singletable.Noise;
import org.hibernate.test.annotations.inheritance.singletable.Rock;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
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 Emmanuel Bernard
*/
@FailureExpectedWithNewMetamodel
public class SubclassTest extends BaseCoreFunctionalTestCase {
@Override
protected boolean isCleanupTestDataRequired() {