FailureExpectedWithNewMetamodel cleanup
This commit is contained in:
parent
2b17b95980
commit
674eeec3a9
|
@ -25,6 +25,7 @@ package org.hibernate.metamodel.source.internal.annotations.entity;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
@ -435,7 +436,7 @@ public class IdentifiableTypeMetadata extends ManagedTypeMetadata {
|
|||
return getSuperType().getIdType();
|
||||
}
|
||||
}
|
||||
return idType;
|
||||
return idType == null ? IdType.NONE : idType;
|
||||
}
|
||||
|
||||
public List<SingularAttribute> getIdentifierAttributes() {
|
||||
|
@ -446,7 +447,7 @@ public class IdentifiableTypeMetadata extends ManagedTypeMetadata {
|
|||
return getSuperType().getIdentifierAttributes();
|
||||
}
|
||||
}
|
||||
return identifierAttributes;
|
||||
return identifierAttributes == null ? Collections.<SingularAttribute>emptyList() : identifierAttributes;
|
||||
}
|
||||
|
||||
public BasicAttribute getVersionAttribute() {
|
||||
|
|
|
@ -444,6 +444,8 @@ public abstract class ManagedTypeMetadata implements OverrideAndConverterCollect
|
|||
private final Set<String> transientFieldNames = new HashSet<String>();
|
||||
private final Set<String> transientMethodNames = new HashSet<String>();
|
||||
|
||||
private final Set<String> processedAttributeNames = new HashSet<String>();
|
||||
|
||||
/**
|
||||
* Collect all persistent attributes for this managed type
|
||||
*/
|
||||
|
@ -463,7 +465,7 @@ public abstract class ManagedTypeMetadata implements OverrideAndConverterCollect
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( persistentAttributeMap.containsKey( attributeName ) ) {
|
||||
if ( processedAttributeNames.contains( attributeName ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -482,7 +484,7 @@ public abstract class ManagedTypeMetadata implements OverrideAndConverterCollect
|
|||
|
||||
final String attributeName = ReflectHelper.getPropertyNameFromGetterMethod( method.getName() );
|
||||
|
||||
if ( persistentAttributeMap.containsKey( attributeName ) ) {
|
||||
if ( processedAttributeNames.contains( attributeName ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -562,6 +564,11 @@ public abstract class ManagedTypeMetadata implements OverrideAndConverterCollect
|
|||
+ "] that did not following JavaBeans naming convention for getter"
|
||||
);
|
||||
}
|
||||
|
||||
if ( processedAttributeNames.contains( attributeName ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
final MethodDescriptor methodDescriptor = findMethodDescriptor(
|
||||
getJavaTypeDescriptor(),
|
||||
methodInfo.name()
|
||||
|
@ -569,11 +576,18 @@ public abstract class ManagedTypeMetadata implements OverrideAndConverterCollect
|
|||
createPersistentAttribute( attributeName, methodDescriptor, attributeAccessType );
|
||||
}
|
||||
else {
|
||||
final FieldInfo fieldInfo = (FieldInfo) annotationTarget;
|
||||
final String attributeName = fieldInfo.name();
|
||||
|
||||
if ( processedAttributeNames.contains( attributeName ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
FieldDescriptor fieldDescriptor = findFieldDescriptor(
|
||||
getJavaTypeDescriptor(),
|
||||
( (FieldInfo) annotationTarget ).name()
|
||||
attributeName
|
||||
);
|
||||
createPersistentAttribute( fieldDescriptor.getName(), fieldDescriptor, attributeAccessType );
|
||||
createPersistentAttribute( attributeName, fieldDescriptor, attributeAccessType );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -746,6 +760,8 @@ public abstract class ManagedTypeMetadata implements OverrideAndConverterCollect
|
|||
member.getType().getErasedType()
|
||||
);
|
||||
|
||||
processedAttributeNames.add( attributeName );
|
||||
|
||||
switch ( attributeCategory ) {
|
||||
case BASIC: {
|
||||
final BasicAttribute attr = new BasicAttribute(
|
||||
|
|
|
@ -185,6 +185,11 @@ public class EntityHierarchyBuilder {
|
|||
private AccessType determineDefaultAccessTypeForHierarchy(JavaTypeDescriptor root) {
|
||||
JavaTypeDescriptor current = root;
|
||||
while ( current != null ) {
|
||||
final AnnotationInstance access = current.findLocalTypeAnnotation( JPADotNames.ACCESS );
|
||||
if ( access != null ) {
|
||||
return AccessType.valueOf( access.value().asEnum() );
|
||||
}
|
||||
|
||||
final Collection<AnnotationInstance> embeddedIdAnnotations = current.findLocalAnnotations(
|
||||
JPADotNames.EMBEDDED_ID
|
||||
);
|
||||
|
|
|
@ -35,13 +35,13 @@ import static org.junit.Assert.assertNotNull;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@FailureExpectedWithNewMetamodel( jiraKey = "HHH-7242", message = "property-ref" )
|
||||
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();
|
||||
|
|
|
@ -137,34 +137,39 @@ public class AccessMappingTest extends BaseUnitTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public void testExplicitPropertyAccessAnnotationsOnField() throws Exception {
|
||||
AnnotationConfiguration cfg = new AnnotationConfiguration();
|
||||
cfg.addAnnotatedClass( Course4.class );
|
||||
cfg.addAnnotatedClass( Student.class );
|
||||
SessionFactory sf= null;
|
||||
try {
|
||||
sf = cfg.buildSessionFactory( serviceRegistry );
|
||||
fail( "@Id and @OneToMany are not placed consistently in test entities. SessionFactory creation should fail." );
|
||||
sf = cfg.buildSessionFactory( serviceRegistry );
|
||||
fail( "@Id and @OneToMany are not placed consistently in test entities. SessionFactory creation should fail." );
|
||||
}
|
||||
catch ( MappingException e ) {
|
||||
// success
|
||||
} finally {
|
||||
if(sf!=null){
|
||||
}
|
||||
finally {
|
||||
if ( sf != null ) {
|
||||
sf.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@FailureExpectedWithNewMetamodel
|
||||
@FailureExpectedWithNewMetamodel(
|
||||
message = "No idea on 2 levels. First, how is this a 'Hibernate-style override'? " +
|
||||
"Second, tbh, not even sure this should pass; doesn't the AccessType#FIELD override" +
|
||||
" belong on the field? The test passes if @Access(AccessType.FIELD) and other" +
|
||||
"annotations are moved from Course3#getId() to Course3#id. Message sent to hibernate-dev " +
|
||||
"mailing list to get additional points of view."
|
||||
)
|
||||
public void testExplicitPropertyAccessAnnotationsWithHibernateStyleOverride() throws Exception {
|
||||
AnnotationConfiguration cfg = new AnnotationConfiguration();
|
||||
Class<?> classUnderTest = Course3.class;
|
||||
cfg.addAnnotatedClass( classUnderTest );
|
||||
cfg.addAnnotatedClass( Course3.class );
|
||||
cfg.addAnnotatedClass( Student.class );
|
||||
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
||||
EntityTuplizer tuplizer = factory.getEntityPersister( classUnderTest.getName() )
|
||||
EntityTuplizer tuplizer = factory.getEntityPersister( Course3.class.getName() )
|
||||
.getEntityMetamodel()
|
||||
.getTuplizer();
|
||||
assertTrue(
|
||||
|
@ -220,7 +225,6 @@ public class AccessMappingTest extends BaseUnitTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
@FailureExpectedWithNewMetamodel
|
||||
public void testDefaultPropertyAccessIsInherited() throws Exception {
|
||||
AnnotationConfiguration cfg = new AnnotationConfiguration();
|
||||
cfg.addAnnotatedClass( Horse.class );
|
||||
|
@ -245,9 +249,8 @@ public class AccessMappingTest extends BaseUnitTestCase {
|
|||
factory.close();
|
||||
}
|
||||
|
||||
@TestForIssue(jiraKey = "HHH-5004")
|
||||
@Test
|
||||
@FailureExpectedWithNewMetamodel
|
||||
@TestForIssue(jiraKey = "HHH-5004")
|
||||
public void testAccessOnClassAndId() throws Exception {
|
||||
AnnotationConfiguration cfg = new AnnotationConfiguration();
|
||||
cfg.addAnnotatedClass( Course8.class );
|
||||
|
|
Loading…
Reference in New Issue