Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type In directory sc8-pr-cvs1:/tmp/cvs-serv26833/type Modified Files: AbstractType.java ArrayType.java BagType.java ComponentType.java CompositeCustomType.java CustomType.java EntityType.java ListType.java ManyToOneType.java MapType.java ObjectType.java OneToOneType.java PersistentCollectionType.java SetType.java SortedMapType.java SortedSetType.java Type.java Log Message: * reworked CompositeUserType * improved some exception handling Index: AbstractType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/AbstractType.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AbstractType.java 19 Feb 2003 02:02:07 -0000 1.7 --- AbstractType.java 6 Apr 2003 10:11:12 -0000 1.8 *************** *** 42,46 **** } ! public Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException, SQLException { if ( cached==null ) { return null; --- 42,46 ---- } ! public Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException { if ( cached==null ) { return null; *************** *** 66,70 **** public Object resolveIdentifier(Object value, SessionImplementor session, Object owner) ! throws HibernateException, SQLException { return value; } --- 66,70 ---- public Object resolveIdentifier(Object value, SessionImplementor session, Object owner) ! throws HibernateException { return value; } Index: ArrayType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/ArrayType.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ArrayType.java 9 Feb 2003 07:41:16 -0000 1.7 --- ArrayType.java 6 Apr 2003 10:11:12 -0000 1.8 *************** *** 67,71 **** Serializable disassembled, Object owner) ! throws HibernateException, SQLException { return new ArrayHolder(session, persister, disassembled, owner); --- 67,71 ---- Serializable disassembled, Object owner) ! throws HibernateException { return new ArrayHolder(session, persister, disassembled, owner); Index: BagType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/BagType.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** BagType.java 9 Feb 2003 07:41:16 -0000 1.7 --- BagType.java 6 Apr 2003 10:11:12 -0000 1.8 *************** *** 3,7 **** import java.io.Serializable; - import java.sql.SQLException; import net.sf.hibernate.HibernateException; --- 3,6 ---- *************** *** 38,42 **** Serializable disassembled, Object owner) ! throws HibernateException, SQLException { return new Bag(session, persister, disassembled, owner); --- 37,41 ---- Serializable disassembled, Object owner) ! throws HibernateException { return new Bag(session, persister, disassembled, owner); Index: ComponentType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/ComponentType.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ComponentType.java 6 Apr 2003 02:28:58 -0000 1.11 --- ComponentType.java 6 Apr 2003 10:11:12 -0000 1.12 *************** *** 313,317 **** public Object assemble(Serializable object, SessionImplementor session, Object owner) ! throws HibernateException, SQLException { if ( object==null ) { --- 313,317 ---- public Object assemble(Serializable object, SessionImplementor session, Object owner) ! throws HibernateException { if ( object==null ) { Index: CompositeCustomType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/CompositeCustomType.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CompositeCustomType.java 6 Apr 2003 02:28:58 -0000 1.1 --- CompositeCustomType.java 6 Apr 2003 10:11:12 -0000 1.2 *************** *** 1,26 **** package net.sf.hibernate.type; import net.sf.hibernate.CompositeUserType; import net.sf.hibernate.HibernateException; import net.sf.hibernate.MappingException; import net.sf.hibernate.engine.Cascades; import net.sf.hibernate.engine.SessionImplementor; import net.sf.hibernate.engine.Cascades.CascadeStyle; import net.sf.hibernate.loader.OuterJoinLoader; ! public class CompositeCustomType ! extends CustomType implements AbstractComponentType { public CompositeCustomType(Class userTypeClass) throws MappingException { ! super(userTypeClass); } public Type[] getSubtypes() { ! return ( (CompositeUserType) getUserType() ).getPropertyTypes(); } public String[] getPropertyNames() { ! return ( (CompositeUserType) getUserType() ).getPropertyNames(); } --- 1,55 ---- + //$Id$ package net.sf.hibernate.type; + import java.io.Serializable; + import java.sql.PreparedStatement; + import java.sql.ResultSet; + import java.sql.SQLException; + + import org.apache.commons.logging.LogFactory; + import net.sf.hibernate.CompositeUserType; import net.sf.hibernate.HibernateException; import net.sf.hibernate.MappingException; import net.sf.hibernate.engine.Cascades; + import net.sf.hibernate.engine.Mapping; + import net.sf.hibernate.engine.SessionFactoryImplementor; import net.sf.hibernate.engine.SessionImplementor; import net.sf.hibernate.engine.Cascades.CascadeStyle; import net.sf.hibernate.loader.OuterJoinLoader; ! public class CompositeCustomType extends AbstractType implements AbstractComponentType { + + private final CompositeUserType userType; + private final String name; public CompositeCustomType(Class userTypeClass) throws MappingException { ! name = userTypeClass.getName(); ! ! try { ! userType = (CompositeUserType) userTypeClass.newInstance(); ! } ! catch (InstantiationException ie) { ! throw new MappingException( "Cannot instantiate custom type: " + userTypeClass.getName() ); ! } ! catch (IllegalAccessException iae) { ! throw new MappingException( "IllegalAccessException trying to instantiate custom type: " + userTypeClass.getName() ); ! } ! catch (ClassCastException cce) { ! throw new MappingException( userTypeClass.getName() + " must implement net.sf.hibernate.UserType" ); ! } ! ! if ( !Serializable.class.isAssignableFrom( userType.returnedClass() ) ) { ! LogFactory.getLog(CustomType.class).warn("custom type does not implement Serializable: " + userTypeClass); ! } } public Type[] getSubtypes() { ! return userType.getPropertyTypes(); } public String[] getPropertyNames() { ! return userType.getPropertyNames(); } *************** *** 39,48 **** throws HibernateException { ! throw new UnsupportedOperationException(); } public Object getPropertyValue(Object component, int i, SessionImplementor session) throws HibernateException { ! return ( (CompositeUserType) getUserType() ).getPropertyValue(component, i); } --- 68,79 ---- throws HibernateException { ! for (int i=0; i<values.length; i++) { ! userType.setPropertyValue( component, i, values[i] ); ! } } public Object getPropertyValue(Object component, int i, SessionImplementor session) throws HibernateException { ! return userType.getPropertyValue(component, i); } *************** *** 52,60 **** public int enableJoinedFetch(int i) { ! return OuterJoinLoader.LAZY; } public boolean isComponentType() { return true; } --- 83,174 ---- public int enableJoinedFetch(int i) { ! return OuterJoinLoader.AUTO; } public boolean isComponentType() { return true; + } + + public Object assemble( + Serializable cached, + SessionImplementor session, + Object owner) + throws HibernateException { + + return userType.assemble(cached, session, owner); + } + + public Object deepCopy(Object value) throws HibernateException { + return userType.deepCopy(value); + } + + public Serializable disassemble(Object value, SessionImplementor session) + throws HibernateException { + return userType.disassemble(value, session); + } + + public boolean equals(Object x, Object y) throws HibernateException { + return userType.equals(x, y); + } + + public int getColumnSpan(Mapping mapping) throws MappingException { + return userType.sqlTypes().length; + } + + public String getName() { + return name; + } + + public Class getReturnedClass() { + return userType.returnedClass(); + } + + public boolean hasNiceEquals() { + return false; + } + + public boolean isMutable() { + return userType.isMutable(); + } + + public Object nullSafeGet( + ResultSet rs, + String name, + SessionImplementor session, + Object owner) + throws HibernateException, SQLException { + + return userType.nullSafeGet(rs, new String[] {name}, session, owner); + } + + public Object nullSafeGet( + ResultSet rs, + String[] names, + SessionImplementor session, + Object owner) + throws HibernateException, SQLException { + + return userType.nullSafeGet(rs, names, session, owner); + } + + public void nullSafeSet( + PreparedStatement st, + Object value, + int index, + SessionImplementor session) + throws HibernateException, SQLException { + + userType.nullSafeSet(st, value, index, session); + + } + + public int[] sqlTypes(Mapping mapping) throws MappingException { + return userType.sqlTypes(); + } + + public String toXML(Object value, SessionFactoryImplementor factory) + throws HibernateException { + + return value.toString(); } Index: CustomType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/CustomType.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CustomType.java 6 Apr 2003 02:28:58 -0000 1.7 --- CustomType.java 6 Apr 2003 10:11:12 -0000 1.8 *************** *** 80,84 **** * @see net.sf.hibernate.type.Type#equals(Object, Object) */ ! public boolean equals(Object x, Object y) { return userType.equals(x, y); } --- 80,84 ---- * @see net.sf.hibernate.type.Type#equals(Object, Object) */ ! public boolean equals(Object x, Object y) throws HibernateException { return userType.equals(x, y); } *************** *** 140,144 **** * @see net.sf.hibernate.type.Type#deepCopy(Object) */ ! public Object deepCopy(Object value) { return userType.deepCopy(value); } --- 140,144 ---- * @see net.sf.hibernate.type.Type#deepCopy(Object) */ ! public Object deepCopy(Object value) throws HibernateException { return userType.deepCopy(value); } Index: EntityType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/EntityType.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** EntityType.java 19 Feb 2003 02:02:07 -0000 1.7 --- EntityType.java 6 Apr 2003 10:11:12 -0000 1.8 *************** *** 84,88 **** } ! public Object assemble(Serializable oid, SessionImplementor session, Object owner) throws HibernateException, SQLException { return resolveIdentifier(oid, session, owner); } --- 84,88 ---- } ! public Object assemble(Serializable oid, SessionImplementor session, Object owner) throws HibernateException { return resolveIdentifier(oid, session, owner); } Index: ListType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/ListType.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ListType.java 9 Feb 2003 07:41:16 -0000 1.7 --- ListType.java 6 Apr 2003 10:11:12 -0000 1.8 *************** *** 3,7 **** import java.io.Serializable; - import java.sql.SQLException; import net.sf.hibernate.HibernateException; --- 3,6 ---- *************** *** 34,38 **** Serializable disassembled, Object owner) ! throws HibernateException, SQLException { return new List(session, persister, disassembled, owner); --- 33,37 ---- Serializable disassembled, Object owner) ! throws HibernateException { return new List(session, persister, disassembled, owner); Index: ManyToOneType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/ManyToOneType.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ManyToOneType.java 19 Feb 2003 02:02:07 -0000 1.5 --- ManyToOneType.java 6 Apr 2003 10:11:13 -0000 1.6 *************** *** 32,36 **** public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { session.getFactory().getIdentifierType( getPersistentClass() ) ! .nullSafeSet(st, getIdentifier(value, session), index, session); } --- 32,36 ---- public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { session.getFactory().getIdentifierType( getPersistentClass() ) ! .nullSafeSet(st, getIdentifier(value, session), index, session); } *************** *** 54,58 **** public Object resolveIdentifier(Object value, SessionImplementor session, Object owner) ! throws HibernateException, SQLException { if (value==null) { --- 54,58 ---- public Object resolveIdentifier(Object value, SessionImplementor session, Object owner) ! throws HibernateException { if (value==null) { Index: MapType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/MapType.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** MapType.java 9 Feb 2003 07:41:16 -0000 1.7 --- MapType.java 6 Apr 2003 10:11:13 -0000 1.8 *************** *** 3,7 **** import java.io.Serializable; - import java.sql.SQLException; import java.util.Iterator; --- 3,6 ---- *************** *** 40,44 **** Serializable disassembled, Object owner) ! throws HibernateException, SQLException { return new Map(session, persister, disassembled, owner); --- 39,43 ---- Serializable disassembled, Object owner) ! throws HibernateException { return new Map(session, persister, disassembled, owner); Index: ObjectType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/ObjectType.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ObjectType.java 6 Apr 2003 02:28:59 -0000 1.7 --- ObjectType.java 6 Apr 2003 10:11:13 -0000 1.8 *************** *** 165,169 **** SessionImplementor session, Object owner) ! throws HibernateException, SQLException { ObjectTypeCacheEntry e = (ObjectTypeCacheEntry) cached; --- 165,169 ---- SessionImplementor session, Object owner) ! throws HibernateException { ObjectTypeCacheEntry e = (ObjectTypeCacheEntry) cached; Index: OneToOneType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/OneToOneType.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** OneToOneType.java 9 Feb 2003 07:41:16 -0000 1.6 --- OneToOneType.java 6 Apr 2003 10:11:13 -0000 1.7 *************** *** 62,66 **** } ! public Object resolveIdentifier(Object value, SessionImplementor session, Object owner) throws HibernateException, SQLException { if (value==null) return null; --- 62,66 ---- } ! public Object resolveIdentifier(Object value, SessionImplementor session, Object owner) throws HibernateException { if (value==null) return null; *************** *** 70,75 **** return isNullable() ? ! session.internalLoadOneToOne(clazz, id) : ! session.internalLoad(clazz, id); } --- 70,75 ---- return isNullable() ? ! session.internalLoadOneToOne(clazz, id) : ! session.internalLoad(clazz, id); } Index: PersistentCollectionType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/PersistentCollectionType.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PersistentCollectionType.java 9 Feb 2003 07:41:16 -0000 1.8 --- PersistentCollectionType.java 6 Apr 2003 10:11:13 -0000 1.9 *************** *** 49,53 **** } ! public Object getCollection(Serializable id, Object owner, SessionImplementor session) throws HibernateException, SQLException { CollectionPersister persister = session.getFactory().getCollectionPersister(role); --- 49,53 ---- } ! public Object getCollection(Serializable id, Object owner, SessionImplementor session) throws HibernateException { CollectionPersister persister = session.getFactory().getCollectionPersister(role); *************** *** 110,114 **** } ! public Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException, SQLException { return resolveIdentifier(cached, session, owner); } --- 110,114 ---- } ! public Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException { return resolveIdentifier(cached, session, owner); } *************** *** 155,159 **** public Object resolveIdentifier(Object value, SessionImplementor session, Object owner) ! throws HibernateException, SQLException { if (value==null) { --- 155,159 ---- public Object resolveIdentifier(Object value, SessionImplementor session, Object owner) ! throws HibernateException { if (value==null) { *************** *** 173,177 **** CollectionPersister persister, Serializable disassembled, ! Object owner) throws HibernateException, SQLException; } --- 173,177 ---- CollectionPersister persister, Serializable disassembled, ! Object owner) throws HibernateException; } Index: SetType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/SetType.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SetType.java 9 Feb 2003 07:41:16 -0000 1.7 --- SetType.java 6 Apr 2003 10:11:13 -0000 1.8 *************** *** 3,7 **** import java.io.Serializable; - import java.sql.SQLException; import net.sf.hibernate.HibernateException; --- 3,6 ---- *************** *** 33,37 **** CollectionPersister persister, Serializable disassembled, ! Object owner) throws HibernateException, SQLException { return new Set(session, persister, disassembled, owner); --- 32,36 ---- CollectionPersister persister, Serializable disassembled, ! Object owner) throws HibernateException { return new Set(session, persister, disassembled, owner); Index: SortedMapType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/SortedMapType.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SortedMapType.java 9 Feb 2003 07:41:16 -0000 1.7 --- SortedMapType.java 6 Apr 2003 10:11:13 -0000 1.8 *************** *** 4,8 **** import java.io.Serializable; - import java.sql.SQLException; import java.util.Comparator; --- 4,7 ---- *************** *** 41,45 **** Serializable disassembled, Object owner) ! throws HibernateException, SQLException { return new SortedMap(session, persister, comparator, disassembled, owner); --- 40,44 ---- Serializable disassembled, Object owner) ! throws HibernateException { return new SortedMap(session, persister, comparator, disassembled, owner); Index: SortedSetType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/SortedSetType.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SortedSetType.java 9 Feb 2003 07:41:16 -0000 1.7 --- SortedSetType.java 6 Apr 2003 10:11:13 -0000 1.8 *************** *** 4,8 **** import java.io.Serializable; - import java.sql.SQLException; import java.util.Comparator; --- 4,7 ---- *************** *** 40,44 **** CollectionPersister persister, Serializable disassembled, ! Object owner) throws HibernateException, SQLException { return new SortedSet(session, persister, comparator, disassembled, owner); --- 39,43 ---- CollectionPersister persister, Serializable disassembled, ! Object owner) throws HibernateException { return new SortedSet(session, persister, comparator, disassembled, owner); Index: Type.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/type/Type.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Type.java 19 Feb 2003 02:02:09 -0000 1.8 --- Type.java 6 Apr 2003 10:11:13 -0000 1.9 *************** *** 201,205 **** * @return the the object */ ! public Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException, SQLException; /** --- 201,205 ---- * @return the the object */ ! public Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException; /** *************** *** 238,242 **** * @throws SQLException */ ! public Object resolveIdentifier(Object value, SessionImplementor session, Object owner) throws HibernateException, SQLException; } --- 238,242 ---- * @throws SQLException */ ! public Object resolveIdentifier(Object value, SessionImplementor session, Object owner) throws HibernateException; } |