From: <one...@us...> - 2003-03-29 04:08:51
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister In directory sc8-pr-cvs1:/tmp/cvs-serv947/hibernate/persister Modified Files: AbstractEntityPersister.java EntityPersister.java NormalizedEntityPersister.java Log Message: * fixed a bug in SQLExpression * fixed a bug in Expression.ge() * improved proxy handling * fixed problems with select new * reworked import mechanism * added <any> mappings Index: AbstractEntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister/AbstractEntityPersister.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** AbstractEntityPersister.java 16 Feb 2003 01:55:06 -0000 1.14 --- AbstractEntityPersister.java 29 Mar 2003 04:08:48 -0000 1.15 *************** *** 116,119 **** --- 116,121 ---- private transient final ReflectHelper.Getter[] getters; private transient final ReflectHelper.Setter[] setters; + private transient final HashMap gettersByPropertyName = new HashMap(); + private transient final HashMap settersByPropertyName = new HashMap(); protected transient final int hydrateSpan; *************** *** 582,609 **** idgen = model.getIdentifier().createIdentifierGenerator(dialect); useIdentityColumn = idgen instanceof IdentityGenerator; ! identitySelectString = (useIdentityColumn) ? dialect.getIdentitySelectString() : null; // UNSAVED-VALUE: ! String cts = model.getIdentifier().getNullValue(); ! if ( cts==null || "any".equals(cts) ) { unsavedIdentifierValue=Cascades.SAVE_ANY; } ! else if ( "none".equals(cts) ) { unsavedIdentifierValue=Cascades.SAVE_NONE; } ! else if ( "null".equals(cts) ) { unsavedIdentifierValue=Cascades.SAVE_NULL; } else { try { ! unsavedIdentifierValue = new Cascades.IdentifierValue( ( (IdentifierType) model.getIdentifier().getType() ).stringToObject(cts) ); } catch (ClassCastException cce) { ! throw new MappingException("Bad identifier type: " + model.getIdentifier().getType().getClass().getName() ); } catch (Exception e) { ! throw new MappingException("Could not parse unsaved-value: " + cts); } } --- 584,612 ---- idgen = model.getIdentifier().createIdentifierGenerator(dialect); useIdentityColumn = idgen instanceof IdentityGenerator; ! identitySelectString = useIdentityColumn ? dialect.getIdentitySelectString() : null; // UNSAVED-VALUE: ! String unsavedValue = model.getIdentifier().getNullValue(); ! if ( unsavedValue==null || "any".equals(unsavedValue) ) { unsavedIdentifierValue=Cascades.SAVE_ANY; } ! else if ( "none".equals(unsavedValue) ) { unsavedIdentifierValue=Cascades.SAVE_NONE; } ! else if ( "null".equals(unsavedValue) ) { unsavedIdentifierValue=Cascades.SAVE_NULL; } else { + Type idType = model.getIdentifier().getType(); try { ! unsavedIdentifierValue = new Cascades.IdentifierValue( ( (IdentifierType) idType ).stringToObject(unsavedValue) ); } catch (ClassCastException cce) { ! throw new MappingException("Bad identifier type: " + idType.getClass().getName() ); } catch (Exception e) { ! throw new MappingException("Could not parse unsaved-value: " + unsavedValue); } } *************** *** 662,665 **** --- 665,671 ---- propertyInsertability[i] = prop.isInsertable(); + gettersByPropertyName.put( propertyNames[i], getters[i] ); + settersByPropertyName.put( propertyNames[i], setters[i] ); + cascadeStyles[i] = prop.getCascadeStyle(); if ( cascadeStyles[i]!=Cascades.STYLE_NONE ) foundCascade = true; *************** *** 759,762 **** --- 765,780 ---- } + public Object getPropertyValue(Object object, String propertyName) + throws HibernateException { + + return ( (ReflectHelper.Getter) gettersByPropertyName.get(propertyName) ).get(object); + } + + public void setPropertyValue(Object object, String propertyName, Object value) + throws HibernateException { + + ( (ReflectHelper.Setter) settersByPropertyName.get(propertyName) ).set(object, value); + } + } Index: EntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister/EntityPersister.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** EntityPersister.java 16 Mar 2003 01:45:52 -0000 1.21 --- EntityPersister.java 29 Mar 2003 04:08:48 -0000 1.22 *************** *** 7,10 **** --- 7,11 ---- import net.sf.hibernate.loader.SimpleEntityLoader; import net.sf.hibernate.loader.UniqueEntityLoader; + import net.sf.hibernate.mapping.Any; import net.sf.hibernate.mapping.Column; import net.sf.hibernate.mapping.Component; *************** *** 29,32 **** --- 30,34 ---- import org.apache.commons.logging.LogFactory; + import net.sf.hibernate.Hibernate; import net.sf.hibernate.HibernateException; import net.sf.hibernate.LockMode; *************** *** 112,116 **** mods.put(idpath, idType); columnNamesByPropertyPath.put(idpath, columns); ! if ( idType.isComponentType() ) { AbstractComponentType actype = (AbstractComponentType) idType; String[] props = actype.getPropertyNames(); --- 114,118 ---- mods.put(idpath, idType); columnNamesByPropertyPath.put(idpath, columns); ! if ( idType.isComponentType() || idType.isObjectType() ) { AbstractComponentType actype = (AbstractComponentType) idType; String[] props = actype.getPropertyNames(); *************** *** 795,799 **** Iterator iter = ( (Component) prop.getValue() ).getPropertyIterator(); while ( iter.hasNext() ) { - typesByPropertyPath.put( path, prop.getType() ); initPropertyPaths( (Property) iter.next(), path + "." ) ; } --- 797,800 ---- *************** *** 809,815 **** Type type = prop.getType(); typesByPropertyPath.put(path, type); - columnNamesByPropertyPath.put(path, names); } --- 810,834 ---- Type type = prop.getType(); + typesByPropertyPath.put(path, type); columnNamesByPropertyPath.put(path, names); + + if ( prop.getValue().isAny() ) { + String idpath = path + ".id"; + String clpath = path + ".class"; + + Any any = (Any) prop.getValue(); + typesByPropertyPath.put( idpath, any.getIdentifierType() ); + typesByPropertyPath.put( clpath, Hibernate.CLASS ); + + iter = any.getColumnIterator(); + columnNamesByPropertyPath.put( clpath, new String[] { ( (Column) iter.next() ).getName() } ); + names = new String[ any.getColumnSpan() - 1 ]; + k=0; + while ( iter.hasNext() ) { + names[k++] = ( (Column) iter.next() ).getName(); + } + columnNamesByPropertyPath.put(idpath, names); + } } Index: NormalizedEntityPersister.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/persister/NormalizedEntityPersister.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** NormalizedEntityPersister.java 16 Mar 2003 01:45:52 -0000 1.14 --- NormalizedEntityPersister.java 29 Mar 2003 04:08:48 -0000 1.15 *************** *** 7,10 **** --- 7,11 ---- import net.sf.hibernate.loader.EntityLoader; import net.sf.hibernate.loader.UniqueEntityLoader; + import net.sf.hibernate.mapping.Any; import net.sf.hibernate.mapping.Column; import net.sf.hibernate.mapping.Component; *************** *** 132,136 **** columnNamesByPropertyPath.put(idpath, columns); tableNumberByPropertyPath.put(idpath, table); ! if ( idType.isComponentType() ) { AbstractComponentType actype = (AbstractComponentType) idType; String[] props = actype.getPropertyNames(); --- 133,137 ---- columnNamesByPropertyPath.put(idpath, columns); tableNumberByPropertyPath.put(idpath, table); ! if ( idType.isComponentType() || idType.isObjectType() ) { AbstractComponentType actype = (AbstractComponentType) idType; String[] props = actype.getPropertyNames(); *************** *** 896,900 **** Iterator iter = ( (Component) prop.getValue() ).getPropertyIterator(); while ( iter.hasNext() ) { - typesByPropertyPath.put( path, prop.getType() ); initPropertyPaths( (Property) iter.next(), path + "." ) ; } --- 897,900 ---- *************** *** 905,924 **** int k=0; while ( iter.hasNext() ) { ! names[k] = ( (Column) iter.next() ).getName(); ! k++; } ! tableNumberByPropertyPath.put( ! path, ! new Integer( getTableId( ! prop.getValue().getTable().getQualifiedName( factory.getDefaultSchema() ), ! subclassTableNameClosure ! ) ) ! ); ! Type type = prop.getType(); typesByPropertyPath.put(path, type); ! columnNamesByPropertyPath.put(path, names); } --- 905,941 ---- int k=0; while ( iter.hasNext() ) { ! names[k++] = ( (Column) iter.next() ).getName(); } ! Integer tabno = new Integer( getTableId( ! prop.getValue().getTable().getQualifiedName( factory.getDefaultSchema() ), ! subclassTableNameClosure ! ) ); ! Type type = prop.getType(); + typesByPropertyPath.put(path, type); ! tableNumberByPropertyPath.put(path, tabno); columnNamesByPropertyPath.put(path, names); + + if ( prop.getValue().isAny() ) { + String idpath = path + ".id"; + String clpath = path + ".class"; + + Any any = (Any) prop.getValue(); + typesByPropertyPath.put( idpath, any.getIdentifierType() ); + typesByPropertyPath.put( clpath, Hibernate.CLASS ); + + iter = any.getColumnIterator(); + columnNamesByPropertyPath.put( clpath, new String[] { ( (Column) iter.next() ).getName() } ); + names = new String[ any.getColumnSpan() - 1 ]; + k=0; + while ( iter.hasNext() ) { + names[k++] = ( (Column) iter.next() ).getName(); + } + columnNamesByPropertyPath.put(idpath, names); + tableNumberByPropertyPath.put(idpath, tabno); + tableNumberByPropertyPath.put(clpath, tabno); + } } |