From: <one...@us...> - 2003-03-29 04:08:55
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type In directory sc8-pr-cvs1:/tmp/cvs-serv947/hibernate/type Modified Files: AbstractComponentType.java ComponentType.java DynaBeanType.java ObjectType.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: AbstractComponentType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/AbstractComponentType.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AbstractComponentType.java 3 Feb 2003 10:28:48 -0000 1.5 --- AbstractComponentType.java 29 Mar 2003 04:08:49 -0000 1.6 *************** *** 6,12 **** /** ! * Enables other Component-like types to hold collections */ - public interface AbstractComponentType extends Type { public Type[] getSubtypes(); --- 6,11 ---- /** ! * Enables other Component-like types to hold collections and have cascades, etc. */ public interface AbstractComponentType extends Type { public Type[] getSubtypes(); Index: ComponentType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/ComponentType.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ComponentType.java 15 Feb 2003 08:00:55 -0000 1.8 --- ComponentType.java 29 Mar 2003 04:08:49 -0000 1.9 *************** *** 218,222 **** if (optimizer!=null) { try { ! optimizer.setPropertyValues(component,values); return; } --- 218,222 ---- if (optimizer!=null) { try { ! optimizer.setPropertyValues(component, values); return; } Index: DynaBeanType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/DynaBeanType.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DynaBeanType.java 3 Feb 2003 10:28:48 -0000 1.3 --- DynaBeanType.java 29 Mar 2003 04:08:49 -0000 1.4 *************** *** 74,79 **** * @see net.sf.hibernate.type.AbstractComponentType#getPropertyValues(java.lang.Object) */ ! public Object[] getPropertyValues(Object component) ! throws HibernateException { DynaBean bean = (DynaBean) component; --- 74,78 ---- * @see net.sf.hibernate.type.AbstractComponentType#getPropertyValues(java.lang.Object) */ ! public Object[] getPropertyValues(Object component) throws HibernateException { DynaBean bean = (DynaBean) component; Index: ObjectType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/ObjectType.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ObjectType.java 19 Feb 2003 02:02:08 -0000 1.5 --- ObjectType.java 29 Mar 2003 04:08:49 -0000 1.6 *************** *** 6,10 **** import java.sql.ResultSet; import java.sql.SQLException; - import java.sql.Types; import net.sf.hibernate.Hibernate; --- 6,9 ---- *************** *** 14,21 **** import net.sf.hibernate.engine.SessionFactoryImplementor; import net.sf.hibernate.engine.SessionImplementor; ! import net.sf.hibernate.util.ReflectHelper; public class ObjectType extends AbstractType { /** * @see net.sf.hibernate.type.Type#deepCopy(Object) --- 13,30 ---- import net.sf.hibernate.engine.SessionFactoryImplementor; import net.sf.hibernate.engine.SessionImplementor; ! import net.sf.hibernate.util.ArrayHelper; public class ObjectType extends AbstractType { + private Type identifierType; + + public ObjectType(Type identifierType) { + this.identifierType = identifierType; + } + + public ObjectType() { + this(Hibernate.SERIALIZABLE); + } + /** * @see net.sf.hibernate.type.Type#deepCopy(Object) *************** *** 79,94 **** //if ( names.length!=2 ) throw new HibernateException("object type mapping must specify exactly two columns"); ! String className = (String) Hibernate.STRING.nullSafeGet( rs, names[0] ); ! Serializable id = (Serializable) Hibernate.SERIALIZABLE.nullSafeGet( rs, names[1] ); ! if (className==null || id==null) { return null; } else { ! try { ! return session.load( ReflectHelper.classForName(className), id ); ! } ! catch (ClassNotFoundException cnfe) { ! throw new HibernateException("Class not found: " + className); ! } } } --- 88,98 ---- //if ( names.length!=2 ) throw new HibernateException("object type mapping must specify exactly two columns"); ! Class clazz = (Class) Hibernate.CLASS.nullSafeGet( rs, names[0] ); ! Serializable id = (Serializable) identifierType.nullSafeGet(rs, names[1], session, owner); ! if (clazz==null || id==null) { return null; } else { ! return session.load(clazz, id); } } *************** *** 100,113 **** throws HibernateException, SQLException { if (value==null) { ! st.setNull(index, Types.VARCHAR); ! st.setNull(index+1, Types.VARBINARY); } else { ! Serializable id = session.getEntityIdentifierIfNotUnsaved(value); ! String className = value.getClass().getName(); ! Hibernate.STRING.nullSafeSet(st, className, index, session); ! Hibernate.SERIALIZABLE.nullSafeSet(st, id, index+1, session); } } --- 104,120 ---- throws HibernateException, SQLException { + Serializable id; + Class clazz; if (value==null) { ! id=null; ! clazz=null; } else { ! id = session.getEntityIdentifierIfNotUnsaved(value); ! clazz = value.getClass(); } + + Hibernate.CLASS.nullSafeSet(st, clazz, index, session); + identifierType.nullSafeSet(st, id, index+1, session); } *************** *** 119,129 **** } ! private static final int[] SQL_TYPES = new int[] { Types.VARCHAR, Types.VARBINARY }; /** * @see net.sf.hibernate.type.Type#sqlTypes(Mapping) */ ! public int[] sqlTypes(Mapping pi) throws MappingException { ! return SQL_TYPES; } --- 126,139 ---- } ! //private static final int[] SQL_TYPES = new int[] { Types.VARCHAR, Types.VARBINARY }; /** * @see net.sf.hibernate.type.Type#sqlTypes(Mapping) */ ! public int[] sqlTypes(Mapping mapping) throws MappingException { ! return ArrayHelper.join( ! Hibernate.CLASS.sqlTypes(mapping), ! identifierType.sqlTypes(mapping) ! ); } *************** *** 162,166 **** public Serializable disassemble(Object value, SessionImplementor session) throws HibernateException { ! return (value==null) ? null : new ObjectTypeCacheEntry( value.getClass(), session.getEntityIdentifier(value) ); } --- 172,181 ---- public Serializable disassemble(Object value, SessionImplementor session) throws HibernateException { ! return (value==null) ? ! null : ! new ObjectTypeCacheEntry( ! value.getClass(), ! session.getEntityIdentifier(value) ! ); } |