From: <one...@us...> - 2003-04-11 07:15:58
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg In directory sc8-pr-cvs1:/tmp/cvs-serv12292/hibernate/cfg Modified Files: Binder.java Log Message: added meta-type to <any> mappings Index: Binder.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/cfg/Binder.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Binder.java 6 Apr 2003 02:28:56 -0000 1.13 --- Binder.java 11 Apr 2003 07:15:52 -0000 1.14 *************** *** 200,204 **** if (propertyName==null) { bindValue(subnode, id, false, RootClass.DEFAULT_IDENTIFIER_COLUMN_NAME); ! if (id.getType()==null) throw new MappingException( "must specify an identifier type: " + model.getPersistentClass().getName() ); model.setIdentifierProperty(null); } --- 200,206 ---- if (propertyName==null) { bindValue(subnode, id, false, RootClass.DEFAULT_IDENTIFIER_COLUMN_NAME); ! if (id.getType()==null) throw new MappingException( ! "must specify an identifier type: " + model.getPersistentClass().getName() ! ); model.setIdentifierProperty(null); } *************** *** 225,229 **** else { Class reflectedClass = ReflectHelper.getGetter( model.getPersistentClass(), propertyName ).getReturnType(); ! bindComponent(subnode, id, reflectedClass, model.getName() + StringHelper.DOT + propertyName, false, mappings); Property prop = new Property(id); bindProperty(subnode, prop, mappings); --- 227,238 ---- else { Class reflectedClass = ReflectHelper.getGetter( model.getPersistentClass(), propertyName ).getReturnType(); ! bindComponent( ! subnode, ! id, ! reflectedClass, ! model.getName() + StringHelper.DOT + propertyName, ! false, ! mappings ! ); Property prop = new Property(id); bindProperty(subnode, prop, mappings); *************** *** 332,336 **** model.setName( getPropertyName(node) ); Type type = model.getValue().getType(); ! if (type==null) throw new MappingException( "Could not determine a property type for: " + model.getName() ); Attribute cascadeNode = node.attribute("cascade"); model.setCascade( (cascadeNode==null) ? --- 341,347 ---- model.setName( getPropertyName(node) ); Type type = model.getValue().getType(); ! if (type==null) throw new MappingException( ! "Could not determine a property type for: " + model.getName() ! ); Attribute cascadeNode = node.attribute("cascade"); model.setCascade( (cascadeNode==null) ? *************** *** 467,470 **** --- 478,487 ---- public static void bindAny(Element node, Any model, boolean isNullable) throws MappingException { model.setIdentifierType( getTypeFromXML(node) ); + Attribute metaAttribute = node.attribute("meta-type"); + if (metaAttribute!=null) { + Type metaType = TypeFactory.hueristicType( metaAttribute.getValue() ); + if ( metaType==null ) throw new MappingException("could not interpret meta-type"); + model.setMetaType(metaType); + } bindColumns(node, model, isNullable, false, null); } *************** *** 478,482 **** model.setConstrained(constrained); ! model.setForeignKeyType(constrained ? AssociationType.FOREIGN_KEY_FROM_PARENT : AssociationType.FOREIGN_KEY_TO_PARENT); Attribute typeNode = node.attribute("class"); --- 495,503 ---- model.setConstrained(constrained); ! model.setForeignKeyType( ! constrained ? ! AssociationType.FOREIGN_KEY_FROM_PARENT : ! AssociationType.FOREIGN_KEY_TO_PARENT ! ); Attribute typeNode = node.attribute("class"); *************** *** 484,488 **** try { model.setType( ! TypeFactory.oneToOne( ReflectHelper.classForName( typeNode.getValue() ), model.getForeignKeyType() ) ); } --- 505,512 ---- try { model.setType( ! TypeFactory.oneToOne( ! ReflectHelper.classForName( typeNode.getValue() ), ! model.getForeignKeyType() ! ) ); } *************** *** 549,553 **** ); } ! else if ( "one-to-many".equals(name) || "many-to-many".equals(name) || "composite-element".equals(name) ) { try { model.setElementClass( --- 573,581 ---- ); } ! else if ( ! "one-to-many".equals(name) || ! "many-to-many".equals(name) || ! "composite-element".equals(name) ! ) { try { model.setElementClass( *************** *** 609,613 **** Value value = null; if (collectType!=null) { ! Collection collection = collectType.create( subnode, path, model.getOwner(), mappings ); mappings.addCollection(collection); value = new Value( model.getTable() ); --- 637,641 ---- Value value = null; if (collectType!=null) { ! Collection collection = collectType.create(subnode, path, model.getOwner(), mappings); mappings.addCollection(collection); value = new Value( model.getTable() ); *************** *** 631,635 **** bindValue(subnode, value, isNullable, propertyName); } ! else if ( "component".equals(name) || "dynabean".equals(name) || "nested-composite-element".equals(name) ) { Class subreflectedClass = (model.getComponentClass()==null) ? null : --- 659,667 ---- bindValue(subnode, value, isNullable, propertyName); } ! else if ( ! "component".equals(name) || ! "dynabean".equals(name) || ! "nested-composite-element".equals(name) ! ) { Class subreflectedClass = (model.getComponentClass()==null) ? null : *************** *** 677,681 **** ( model.getComponentClass()==null ) ? (Type) new DynaBeanType(model.getDynaClass(), names, types, joinedFetch, cascade) : ! (Type) new ComponentType( model.getComponentClass(), names, types, joinedFetch, cascade, model.getParentProperty(), model.isEmbedded() ) ); } --- 709,721 ---- ( model.getComponentClass()==null ) ? (Type) new DynaBeanType(model.getDynaClass(), names, types, joinedFetch, cascade) : ! (Type) new ComponentType( ! model.getComponentClass(), ! names, ! types, ! joinedFetch, ! cascade, ! model.getParentProperty(), ! model.isEmbedded() ! ) ); } |