HHH-6173 Passing association and attribute overrides to EmbeddedClass

This commit is contained in:
Hardy Ferentschik 2011-06-22 23:11:12 +02:00
parent fcbca08a1f
commit 08ed4c1e80
3 changed files with 67 additions and 1 deletions

View File

@ -81,6 +81,16 @@ public class ConfiguredClass {
*/ */
private final ConfiguredClassType configuredClassType; private final ConfiguredClassType configuredClassType;
/**
* The attribute overrides defined on this entity
*/
private final List<AnnotationInstance> attributeOverrides;
/**
* The association overrides defined on this entity;
*/
private final List<AnnotationInstance> associationOverrides;
/** /**
* The mapped attributes for entity * The mapped attributes for entity
*/ */
@ -106,6 +116,9 @@ public class ConfiguredClass {
this.configuredClassType = determineType(); this.configuredClassType = determineType();
this.classAccessType = determineClassAccessType( defaultAccessType ); this.classAccessType = determineClassAccessType( defaultAccessType );
this.attributeOverrides = findAttributeOverrides();
this.associationOverrides = findAssociationOverrides();
// find transient field and method names // find transient field and method names
findTransientFieldAndMethodNames(); findTransientFieldAndMethodNames();
@ -388,6 +401,8 @@ public class ConfiguredClass {
embeddableClassInfo, embeddableClassInfo,
classAccessType, classAccessType,
context.resolveType( type.getName() ), context.resolveType( type.getName() ),
attributeOverrides,
associationOverrides,
context context
); );
@ -480,4 +495,50 @@ public class ConfiguredClass {
} }
} }
} }
private List<AnnotationInstance> findAttributeOverrides() {
List<AnnotationInstance> attributeOverrideList = new ArrayList<AnnotationInstance>();
AnnotationInstance attributeOverrideAnnotation = JandexHelper.getSingleAnnotation(
classInfo,
JPADotNames.ATTRIBUTE_OVERRIDE
);
if ( attributeOverrideAnnotation != null ) {
attributeOverrideList.add( attributeOverrideAnnotation );
}
AnnotationInstance attributeOverridesAnnotation = JandexHelper.getSingleAnnotation(
classInfo,
JPADotNames.ATTRIBUTE_OVERRIDES
);
if ( attributeOverrideAnnotation != null ) {
AnnotationInstance[] attributeOverride = attributeOverridesAnnotation.value().asNestedArray();
Collections.addAll( attributeOverrideList, attributeOverride );
}
return attributeOverrideList;
}
private List<AnnotationInstance> findAssociationOverrides() {
List<AnnotationInstance> associationOverrideList = new ArrayList<AnnotationInstance>();
AnnotationInstance associationOverrideAnnotation = JandexHelper.getSingleAnnotation(
classInfo,
JPADotNames.ASSOCIATION_OVERRIDE
);
if ( associationOverrideAnnotation != null ) {
associationOverrideList.add( associationOverrideAnnotation );
}
AnnotationInstance associationOverridesAnnotation = JandexHelper.getSingleAnnotation(
classInfo,
JPADotNames.ASSOCIATION_OVERRIDES
);
if ( associationOverrideAnnotation != null ) {
AnnotationInstance[] attributeOverride = associationOverridesAnnotation.value().asNestedArray();
Collections.addAll( associationOverrideList, attributeOverride );
}
return associationOverrideList;
}
} }

View File

@ -23,18 +23,23 @@
*/ */
package org.hibernate.metamodel.source.annotations.entity; package org.hibernate.metamodel.source.annotations.entity;
import java.util.List;
import javax.persistence.AccessType; import javax.persistence.AccessType;
import com.fasterxml.classmate.ResolvedTypeWithMembers; import com.fasterxml.classmate.ResolvedTypeWithMembers;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo; import org.jboss.jandex.ClassInfo;
/** /**
* @author Hardy Ferentschik * @author Hardy Ferentschik
*/ */
public class EmbeddedClass extends ConfiguredClass { public class EmbeddedClass extends ConfiguredClass {
// todo - need to take care of the attribute path (HF)
public EmbeddedClass(ClassInfo classInfo, public EmbeddedClass(ClassInfo classInfo,
AccessType defaultAccessType, AccessType defaultAccessType,
ResolvedTypeWithMembers resolvedType, ResolvedTypeWithMembers resolvedType,
List<AnnotationInstance> attributeOverrides,
List<AnnotationInstance> associationOverrides,
AnnotationBindingContext context) { AnnotationBindingContext context) {
super( classInfo, defaultAccessType, resolvedType, context ); super( classInfo, defaultAccessType, resolvedType, context );
} }

View File

@ -280,7 +280,7 @@ public class EntityBindingStateImpl implements EntityBindingState {
} }
@Override @Override
public Class getCustomEntityPersisterClass() { public Class<EntityPersister> getCustomEntityPersisterClass() {
return persisterClass; return persisterClass;
} }