FailureExpectedWithNewMetamodel cleanup

This commit is contained in:
Steve Ebersole 2014-03-25 22:08:10 -05:00
parent bab7fc6a47
commit 2b17b95980
8 changed files with 42 additions and 46 deletions

View File

@ -61,6 +61,7 @@ import org.hibernate.id.PersistentIdentifierGenerator;
import org.hibernate.id.enhanced.TableGenerator;
import org.hibernate.internal.FilterConfiguration;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.internal.binder.HibernateTypeHelper.ReflectedCollectionJavaTypes;
import org.hibernate.metamodel.internal.resolver.AssociationRelationalBindingResolver;
import org.hibernate.metamodel.internal.resolver.MappedByAssociationRelationalBindingResolverImpl;
@ -1569,10 +1570,7 @@ public class Binder {
}
}
else {
joinRelationalValueBindings = new ArrayList<RelationalValueBinding>(
joinedPrimaryKeyColumnSources
.size()
);
joinRelationalValueBindings = CollectionHelper.arrayList( joinedPrimaryKeyColumnSources.size() );
if ( primaryKeyColumns.size() != joinedPrimaryKeyColumnSources.size() ) {
throw localBindingContext().makeMappingException(
String.format(

View File

@ -44,6 +44,7 @@ import org.hibernate.metamodel.spi.NaturalIdMutability;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue;
import org.jboss.logging.Logger;
/**
* Base class for the different types of persistent attributes
@ -52,6 +53,8 @@ import org.jboss.jandex.AnnotationValue;
* @author Hardy Ferentschik
*/
public abstract class AbstractPersistentAttribute implements PersistentAttribute {
private static final Logger log = Logger.getLogger( AbstractPersistentAttribute.class );
private final ManagedTypeMetadata container;
private final String attributeName;
private final AttributePath attributePath;
@ -163,6 +166,12 @@ public abstract class AbstractPersistentAttribute implements PersistentAttribute
final AnnotationInstance idAnnotation = backingMember.getAnnotations().get( JPADotNames.ID );
if ( idAnnotation != null ) {
validatePresenceOfIdAnnotation();
if ( backingMember.getType().getErasedType().findTypeAnnotation( JPADotNames.EMBEDDABLE ) != null ) {
log.warn(
"Attribute was annotated with @Id, but attribute type was annotated as @Embeddable; " +
"did you mean to use @EmbeddedId on the attribute rather than @Id?"
);
}
return true;
}

View File

@ -42,7 +42,6 @@ import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.metamodel.reflite.internal.ModifierUtils;
import org.hibernate.metamodel.reflite.spi.ArrayDescriptor;
import org.hibernate.metamodel.reflite.spi.ClassDescriptor;
import org.hibernate.metamodel.reflite.spi.FieldDescriptor;
import org.hibernate.metamodel.reflite.spi.JavaTypeDescriptor;
@ -973,10 +972,10 @@ public abstract class ManagedTypeMetadata implements OverrideAndConverterCollect
if ( isEmbeddableType( attributeType ) ) {
LOG.warnf(
"Class %s was annotated as @Embeddable. However a persistent attribute [%s] " +
"of this type was found that did not contain the @Embedded annotation. " +
"of this type was found that did not contain the @Embedded (or @EmbeddedId) annotation. " +
"This may cause compatibility issues",
attributeType.getName(),
member.toString()
member.toLoggableForm()
);
categories.add( AttributeCategorization.EMBEDDED );
}
@ -1042,13 +1041,6 @@ public abstract class ManagedTypeMetadata implements OverrideAndConverterCollect
}
@SuppressWarnings("RedundantIfStatement")
private boolean isCollectionOrArray(JavaTypeDescriptor attributeType) {
return ArrayDescriptor.class.isInstance( attributeType )
|| getLocalBindingContext().getJavaTypeDescriptorRepository().jdkMapDescriptor().isAssignableFrom( attributeType )
|| getLocalBindingContext().getJavaTypeDescriptorRepository().jdkCollectionDescriptor().isAssignableFrom( attributeType );
}
protected boolean isEmbeddableType(JavaTypeDescriptor descriptor) {
return descriptor.findTypeAnnotation( JPADotNames.EMBEDDABLE ) != null;
}

View File

@ -35,7 +35,6 @@ import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.metamodel.spi.binding.Caching;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
import org.hibernate.testing.junit4.Resources;
import org.junit.Test;
@ -43,7 +42,6 @@ import org.junit.Test;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static org.junit.Assert.assertFalse;
/**
* Tests for {@code o.h.a.Cache} and {@code j.p.Cacheable}.
@ -77,12 +75,12 @@ public class CacheBindingTest extends BaseAnnotationBindingTestCase {
@Test
@Resources(annotatedClasses = NoCacheEntity.class, cacheMode = SharedCacheMode.NONE)
@FailureExpectedWithNewMetamodel( message = "I am not so sure that bindings/metamodel is the right place to deal with SharedCacheMode" )
public void testNoCaching() {
EntityBinding binding = getEntityBinding( NoCacheEntity.class );
assertFalse(
assertEquals(
"There should be no cache binding",
binding.getHierarchyDetails().getCaching().getRequested() != TruthValue.TRUE
TruthValue.FALSE,
binding.getHierarchyDetails().getCaching().getRequested()
);
}

View File

@ -23,25 +23,25 @@
*/
package org.hibernate.test.abstractembeddedcomponents.propertyref;
import org.junit.Test;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class AbstractComponentPropertyRefTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() {
return new String[] { "abstractembeddedcomponents/propertyref/Mappings.hbm.xml" };
}
@Test
@FailureExpectedWithNewMetamodel( jiraKey = "HHH-7242", message = "property-ref" )
public void testPropertiesRefCascades() {
Session session = openSession();
Transaction trans = session.beginTransaction();

View File

@ -23,16 +23,15 @@
*/
package org.hibernate.test.annotations;
import org.junit.Test;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.annotations.inheritance.Carrot;
import org.hibernate.test.annotations.inheritance.Tomato;
import org.hibernate.test.annotations.inheritance.Vegetable;
import org.hibernate.test.annotations.inheritance.VegetablePk;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@ -41,7 +40,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Emmanuel Bernard
*/
@FailureExpectedWithNewMetamodel
public class JoinedSubclassTest extends BaseCoreFunctionalTestCase {
@Test
public void testDefaultValues() {
@ -129,6 +127,7 @@ public class JoinedSubclassTest extends BaseCoreFunctionalTestCase {
AmericaCupClass.class,
Country.class,
Vegetable.class,
VegetablePk.class,
Carrot.class,
Tomato.class
};

View File

@ -1,5 +1,5 @@
//$Id$
package org.hibernate.test.annotations.inheritance;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;

View File

@ -1,5 +1,5 @@
//$Id$
package org.hibernate.test.annotations.inheritance;
import java.io.Serializable;
import javax.persistence.Embeddable;
@ -9,6 +9,23 @@ import javax.persistence.Embeddable;
@Embeddable
public class VegetablePk implements Serializable {
private String farmer;
private String harvestDate;
public String getFarmer() {
return farmer;
}
public void setFarmer(String farmer) {
this.farmer = farmer;
}
public String getHarvestDate() {
return harvestDate;
}
public void setHarvestDate(String harvestDate) {
this.harvestDate = harvestDate;
}
public boolean equals(Object o) {
if ( this == o ) return true;
@ -29,21 +46,4 @@ public class VegetablePk implements Serializable {
return result;
}
public String getFarmer() {
return farmer;
}
public void setFarmer(String farmer) {
this.farmer = farmer;
}
public String getHarvestDate() {
return harvestDate;
}
public void setHarvestDate(String harvestDate) {
this.harvestDate = harvestDate;
}
private String harvestDate;
}