From: <epb...@us...> - 2006-02-13 18:18:38
|
Update of /cvsroot/hibernate/HibernateExt/metadata/src/java/org/hibernate/cfg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32558/metadata/src/java/org/hibernate/cfg Modified Files: AnnotationBinder.java PropertyHolderBuilder.java Log Message: ANN-223 generate disc value even for integers and raise an exception for chars ANN-240 inital work, need test and refinement for @Embeddable Index: AnnotationBinder.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/metadata/src/java/org/hibernate/cfg/AnnotationBinder.java,v retrieving revision 1.173 retrieving revision 1.174 diff -u -d -r1.173 -r1.174 --- AnnotationBinder.java 11 Feb 2006 02:50:57 -0000 1.173 +++ AnnotationBinder.java 13 Feb 2006 18:18:25 -0000 1.174 @@ -469,11 +469,12 @@ constraints, inheritanceState.hasDenormalizedTable() ? superEntity.getTable() : null ); } - Map<String, Column[]> columnOverride = PropertyHolderBuilder.buildColumnOverride( - annotatedClass, + Map<String, Column[]> columnOverride = PropertyHolderBuilder.buildHierarchyColumnOverride( + clazzToProcess, persistentClass.getClassName() ); PropertyHolder propertyHolder = PropertyHolderBuilder.buildPropertyHolder( + //clazzToProcess, persistentClass, columnOverride, entityBinder.getSecondaryTables() @@ -525,6 +526,7 @@ entityBinder.getSecondaryTables(), propertyHolder ); + entityBinder.bindDiscriminatorValue();//bind it again since the type might have changed } } } @@ -1476,6 +1478,7 @@ String subpath = StringHelper.qualify( propertyHolder.getPath(), inferredData.getPropertyName() ); log.debug( "Binding component with path: " + subpath ); Map<String, Column[]> localColumnOverride = propertyHolder.mergeOverridenColumns( columnOverride ); + //TODO work on it PropertyHolder subHolder = PropertyHolderBuilder.buildPropertyHolder( comp, subpath, localColumnOverride ); List<PropertyAnnotatedElement> classElements = new ArrayList<PropertyAnnotatedElement>(); XClass returnedClassOrElement = inferredData.getReturnedClassOrElement(); @@ -1514,7 +1517,9 @@ String generatorType, String generatorName, PropertyData inferredData, Ejb3Column[] columns, PropertyHolder propertyHolder, Map<String, IdGenerator> localGenerators, - boolean isComposite, Map<String, Column[]> columnOverride, boolean isPropertyAnnotated, + boolean isComposite, + Map<String, Column[]> columnOverride, + boolean isPropertyAnnotated, String propertyAccessor, EntityBinder entityBinder, Type typeAnn, boolean isEmbedded, ExtendedMappings mappings ) { Index: PropertyHolderBuilder.java =================================================================== RCS file: /cvsroot/hibernate/HibernateExt/metadata/src/java/org/hibernate/cfg/PropertyHolderBuilder.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- PropertyHolderBuilder.java 25 Jan 2006 21:48:21 -0000 1.9 +++ PropertyHolderBuilder.java 13 Feb 2006 18:18:25 -0000 1.10 @@ -6,12 +6,17 @@ import javax.persistence.AttributeOverride; import javax.persistence.AttributeOverrides; import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.MappedSuperclass; +import javax.persistence.Embeddable; import org.hibernate.mapping.Collection; import org.hibernate.mapping.Component; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Join; import org.hibernate.reflection.XAnnotatedElement; +import org.hibernate.reflection.XClass; +import org.hibernate.reflection.ReflectionManager; import org.hibernate.util.StringHelper; /** @@ -24,8 +29,13 @@ } public static PropertyHolder buildPropertyHolder( + //XClass clazzToProcess, PersistentClass persistentClass, Map<String, Column[]> columnOverride, Map<String, Join> joins ) { +// Map<String, Column[]> columnOverride = PropertyHolderBuilder.buildHierarchyColumnOverride( +// clazzToProcess, +// persistentClass.getClassName() +// ); return (PropertyHolder) new ClassPropertyHolder( persistentClass, columnOverride, joins ); } @@ -53,6 +63,23 @@ return buildPropertyHolder( persistentClass, new HashMap<String, Column[]>(), joins ); } + public static Map<String, Column[]> buildHierarchyColumnOverride(XClass element, String path) { + XClass current = element; + Map<String, Column[]> columnOverride = new HashMap<String, Column[]>(); + while ( ! ReflectionManager.INSTANCE.toXClass( Object.class ).equals( current ) ) { + if ( current.isAnnotationPresent(Entity.class) || current.isAnnotationPresent(MappedSuperclass.class) + || current.isAnnotationPresent(Embeddable.class) ) { + //FIXME is embeddable override? + Map<String, Column[]> currentOverride = buildColumnOverride( element, path ); + currentOverride.putAll(columnOverride); //subclasses have precedence over superclasses + columnOverride = currentOverride; + } + current = current.getSuperclass(); + } + + return columnOverride; + } + public static Map<String, Column[]> buildColumnOverride(XAnnotatedElement element, String path) { AttributeOverride singleOverride = element.getAnnotation( AttributeOverride.class ); AttributeOverrides multipleOverrides = element.getAnnotation( AttributeOverrides.class ); |