From: <one...@us...> - 2002-11-26 03:38:02
|
Update of /cvsroot/hibernate/Hibernate/cirrus/hibernate/type In directory sc8-pr-cvs1:/tmp/cvs-serv20166/cirrus/hibernate/type Modified Files: AssociationType.java CalendarDateType.java CalendarType.java ComponentType.java CurrencyType.java DoubleType.java IdentifierType.java LiteralType.java TimeZoneType.java Log Message: fixed broken line-endings and added a test Index: AssociationType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/AssociationType.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AssociationType.java 3 Oct 2002 17:03:28 -0000 1.5 --- AssociationType.java 26 Nov 2002 03:35:45 -0000 1.6 *************** *** 1,43 **** ! //$Id$ ! package cirrus.hibernate.type; ! ! import cirrus.hibernate.engine.Cascades; ! ! /** ! * A type that represents some kind of association between entities. ! * @see cirrus.hibernate.engine.Cascades ! */ ! public interface AssociationType { ! /** ! * Represents directionality of the foreign key constraint ! */ ! public static abstract class ForeignKeyType { ! protected ForeignKeyType() {} ! /** ! * Should we cascade at this cascade point? ! * @see cirrus.hibernate.engine.Cascades ! */ ! public abstract boolean cascadeNow(int cascadePoint); ! } ! /** ! * A foreign key from child to parent ! */ ! public static final ForeignKeyType FOREIGN_KEY_TO_PARENT = new ForeignKeyType() { ! public boolean cascadeNow(int cascadePoint) { ! return cascadePoint!=Cascades.CASCADE_BEFORE_INSERT_AFTER_DELETE; ! } ! }; ! /** ! * A foreign key from parent to child ! */ ! public static final ForeignKeyType FOREIGN_KEY_FROM_PARENT = new ForeignKeyType() { ! public boolean cascadeNow(int cascadePoint) { ! return cascadePoint!=Cascades.CASCADE_AFTER_INSERT_BEFORE_DELETE; ! } ! }; ! ! /** ! * Get the foreign key directionality of this association ! */ ! public ForeignKeyType getForeignKeyType(); ! } --- 1,43 ---- ! //$Id$ ! package cirrus.hibernate.type; ! ! import cirrus.hibernate.engine.Cascades; ! ! /** ! * A type that represents some kind of association between entities. ! * @see cirrus.hibernate.engine.Cascades ! */ ! public interface AssociationType { ! /** ! * Represents directionality of the foreign key constraint ! */ ! public static abstract class ForeignKeyType { ! protected ForeignKeyType() {} ! /** ! * Should we cascade at this cascade point? ! * @see cirrus.hibernate.engine.Cascades ! */ ! public abstract boolean cascadeNow(int cascadePoint); ! } ! /** ! * A foreign key from child to parent ! */ ! public static final ForeignKeyType FOREIGN_KEY_TO_PARENT = new ForeignKeyType() { ! public boolean cascadeNow(int cascadePoint) { ! return cascadePoint!=Cascades.CASCADE_BEFORE_INSERT_AFTER_DELETE; ! } ! }; ! /** ! * A foreign key from parent to child ! */ ! public static final ForeignKeyType FOREIGN_KEY_FROM_PARENT = new ForeignKeyType() { ! public boolean cascadeNow(int cascadePoint) { ! return cascadePoint!=Cascades.CASCADE_AFTER_INSERT_BEFORE_DELETE; ! } ! }; ! ! /** ! * Get the foreign key directionality of this association ! */ ! public ForeignKeyType getForeignKeyType(); ! } Index: CalendarDateType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/CalendarDateType.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CalendarDateType.java 22 Nov 2002 00:27:09 -0000 1.1 --- CalendarDateType.java 26 Nov 2002 03:35:45 -0000 1.2 *************** *** 1,89 **** ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.sql.Date; ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! import java.sql.Types; ! import java.util.Calendar; ! import java.util.GregorianCalendar; ! ! import cirrus.hibernate.HibernateException; ! ! /** ! * A type mapping for a <tt>Calendar</tt> object that represents a date. ! */ ! public class CalendarDateType extends MutableType { ! ! /** ! * @see cirrus.hibernate.type.NullableType#get(ResultSet, String) ! */ ! public Object get(ResultSet rs, String name) ! throws HibernateException, SQLException { ! Calendar cal = new GregorianCalendar(); ! cal.setTimeInMillis( rs.getDate(name).getTime() ); ! return cal; ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#set(PreparedStatement, Object, int) ! */ ! public void set(PreparedStatement st, Object value, int index) ! throws HibernateException, SQLException { ! ! st.setDate( index, new Date( ( (Calendar) value ).getTimeInMillis() ) ); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#sqlType() ! */ ! public int sqlType() { ! return Types.DATE; ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#toXML(Object) ! */ ! public String toXML(Object value) throws HibernateException { ! //TODO: ! return value.toString(); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#deepCopyNotNull(Object) ! */ ! public Object deepCopyNotNull(Object value) throws HibernateException { ! return ( (Calendar) value ).clone(); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#returnedClass() ! */ ! public Class returnedClass() { ! return Calendar.class; ! } ! ! /** ! * @see cirrus.hibernate.type.Type#equals(Object, Object) ! */ ! public boolean equals(Object x, Object y) throws HibernateException { ! if (x==y) return true; ! if (x==null || y==null) return false; ! ! Calendar calendar1 = (Calendar) x; ! Calendar calendar2 = (Calendar) y; ! ! return calendar1.get(Calendar.DAY_OF_MONTH) == calendar2.get(Calendar.DAY_OF_MONTH) ! && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH) ! && calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#getName() ! */ ! public String getName() { ! return "calendar_date"; ! } ! ! } --- 1,89 ---- ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.sql.Date; ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! import java.sql.Types; ! import java.util.Calendar; ! import java.util.GregorianCalendar; ! ! import cirrus.hibernate.HibernateException; ! ! /** ! * A type mapping for a <tt>Calendar</tt> object that represents a date. ! */ ! public class CalendarDateType extends MutableType { ! ! /** ! * @see cirrus.hibernate.type.NullableType#get(ResultSet, String) ! */ ! public Object get(ResultSet rs, String name) ! throws HibernateException, SQLException { ! Calendar cal = new GregorianCalendar(); ! cal.setTimeInMillis( rs.getDate(name).getTime() ); ! return cal; ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#set(PreparedStatement, Object, int) ! */ ! public void set(PreparedStatement st, Object value, int index) ! throws HibernateException, SQLException { ! ! st.setDate( index, new Date( ( (Calendar) value ).getTimeInMillis() ) ); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#sqlType() ! */ ! public int sqlType() { ! return Types.DATE; ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#toXML(Object) ! */ ! public String toXML(Object value) throws HibernateException { ! //TODO: ! return value.toString(); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#deepCopyNotNull(Object) ! */ ! public Object deepCopyNotNull(Object value) throws HibernateException { ! return ( (Calendar) value ).clone(); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#returnedClass() ! */ ! public Class returnedClass() { ! return Calendar.class; ! } ! ! /** ! * @see cirrus.hibernate.type.Type#equals(Object, Object) ! */ ! public boolean equals(Object x, Object y) throws HibernateException { ! if (x==y) return true; ! if (x==null || y==null) return false; ! ! Calendar calendar1 = (Calendar) x; ! Calendar calendar2 = (Calendar) y; ! ! return calendar1.get(Calendar.DAY_OF_MONTH) == calendar2.get(Calendar.DAY_OF_MONTH) ! && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH) ! && calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#getName() ! */ ! public String getName() { ! return "calendar_date"; ! } ! ! } Index: CalendarType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/CalendarType.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CalendarType.java 22 Nov 2002 00:27:09 -0000 1.2 --- CalendarType.java 26 Nov 2002 03:35:45 -0000 1.3 *************** *** 1,101 **** ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! import java.sql.Timestamp; ! import java.sql.Types; ! import java.util.Calendar; ! import java.util.GregorianCalendar; ! ! import cirrus.hibernate.HibernateException; ! ! /** ! * A type mapping for a <tt>Calendar</tt> object that represents a datetime. ! */ ! public class CalendarType extends MutableType { ! ! /** ! * @see cirrus.hibernate.type.NullableType#get(ResultSet, String) ! */ ! public Object get(ResultSet rs, String name) ! throws HibernateException, SQLException { ! ! Timestamp ts = rs.getTimestamp(name); ! if (ts!=null) { ! Calendar cal = new GregorianCalendar(); ! cal.setTimeInMillis( ts.getTime() ); ! return cal; ! } ! else { ! return null; ! } ! ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#set(PreparedStatement, Object, int) ! */ ! public void set(PreparedStatement st, Object value, int index) ! throws HibernateException, SQLException { ! ! st.setTimestamp( index, new Timestamp( ( (Calendar) value ).getTimeInMillis() ) ); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#sqlType() ! */ ! public int sqlType() { ! return Types.TIMESTAMP; ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#toXML(Object) ! */ ! public String toXML(Object value) throws HibernateException { ! //TODO: ! return value.toString(); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#deepCopyNotNull(Object) ! */ ! public Object deepCopyNotNull(Object value) throws HibernateException { ! return ( (Calendar) value ).clone(); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#returnedClass() ! */ ! public Class returnedClass() { ! return Calendar.class; ! } ! ! /** ! * @see cirrus.hibernate.type.Type#equals(Object, Object) ! */ ! public boolean equals(Object x, Object y) throws HibernateException { ! if (x==y) return true; ! if (x==null || y==null) return false; ! ! Calendar calendar1 = (Calendar) x; ! Calendar calendar2 = (Calendar) y; ! ! return calendar1.get(Calendar.MILLISECOND) == calendar2.get(Calendar.MILLISECOND) ! && calendar1.get(Calendar.SECOND) == calendar2.get(Calendar.SECOND) ! && calendar1.get(Calendar.MINUTE) == calendar2.get(Calendar.MINUTE) ! && calendar1.get(Calendar.HOUR_OF_DAY) == calendar2.get(Calendar.HOUR_OF_DAY) ! && calendar1.get(Calendar.DAY_OF_MONTH) == calendar2.get(Calendar.DAY_OF_MONTH) ! && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH) ! && calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#getName() ! */ ! public String getName() { ! return "calendar"; ! } ! ! } --- 1,101 ---- ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! import java.sql.Timestamp; ! import java.sql.Types; ! import java.util.Calendar; ! import java.util.GregorianCalendar; ! ! import cirrus.hibernate.HibernateException; ! ! /** ! * A type mapping for a <tt>Calendar</tt> object that represents a datetime. ! */ ! public class CalendarType extends MutableType { ! ! /** ! * @see cirrus.hibernate.type.NullableType#get(ResultSet, String) ! */ ! public Object get(ResultSet rs, String name) ! throws HibernateException, SQLException { ! ! Timestamp ts = rs.getTimestamp(name); ! if (ts!=null) { ! Calendar cal = new GregorianCalendar(); ! cal.setTimeInMillis( ts.getTime() ); ! return cal; ! } ! else { ! return null; ! } ! ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#set(PreparedStatement, Object, int) ! */ ! public void set(PreparedStatement st, Object value, int index) ! throws HibernateException, SQLException { ! ! st.setTimestamp( index, new Timestamp( ( (Calendar) value ).getTimeInMillis() ) ); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#sqlType() ! */ ! public int sqlType() { ! return Types.TIMESTAMP; ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#toXML(Object) ! */ ! public String toXML(Object value) throws HibernateException { ! //TODO: ! return value.toString(); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#deepCopyNotNull(Object) ! */ ! public Object deepCopyNotNull(Object value) throws HibernateException { ! return ( (Calendar) value ).clone(); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#returnedClass() ! */ ! public Class returnedClass() { ! return Calendar.class; ! } ! ! /** ! * @see cirrus.hibernate.type.Type#equals(Object, Object) ! */ ! public boolean equals(Object x, Object y) throws HibernateException { ! if (x==y) return true; ! if (x==null || y==null) return false; ! ! Calendar calendar1 = (Calendar) x; ! Calendar calendar2 = (Calendar) y; ! ! return calendar1.get(Calendar.MILLISECOND) == calendar2.get(Calendar.MILLISECOND) ! && calendar1.get(Calendar.SECOND) == calendar2.get(Calendar.SECOND) ! && calendar1.get(Calendar.MINUTE) == calendar2.get(Calendar.MINUTE) ! && calendar1.get(Calendar.HOUR_OF_DAY) == calendar2.get(Calendar.HOUR_OF_DAY) ! && calendar1.get(Calendar.DAY_OF_MONTH) == calendar2.get(Calendar.DAY_OF_MONTH) ! && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH) ! && calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#getName() ! */ ! public String getName() { ! return "calendar"; ! } ! ! } Index: ComponentType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/ComponentType.java,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** ComponentType.java 9 Nov 2002 01:49:23 -0000 1.46 --- ComponentType.java 26 Nov 2002 03:35:45 -0000 1.47 *************** *** 1,278 **** ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.io.Serializable; ! import java.lang.reflect.Constructor; ! import java.lang.reflect.Method; ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.InstantiationException; ! import cirrus.hibernate.MappingException; ! import cirrus.hibernate.engine.Cascades; ! import cirrus.hibernate.engine.Mapping; ! import cirrus.hibernate.engine.SessionFactoryImplementor; ! import cirrus.hibernate.engine.SessionImplementor; ! import cirrus.hibernate.helpers.ArrayHelper; ! import cirrus.hibernate.helpers.ReflectHelper; ! ! public class ComponentType extends AbstractType implements AbstractComponentType { ! ! private final Class componentClass; ! private final Constructor constructor; ! private final Type[] types; ! private final Method[] getters; ! private final Method[] setters; ! private final String[] propertyNames; ! private final Cascades.CascadeStyle[] cascade; ! private final int propertySpan; ! private final int[] joinedFetch; ! private final String parentProperty; ! private final Method parentSetter; ! ! public int[] sqlTypes(Mapping pi) throws MappingException { ! //Not called at runtime so doesn't matter if its slow :) ! int[] sqlTypes = new int[ getColumnSpan(pi) ]; ! int n=0; ! for ( int i=0; i<propertySpan; i++ ) { ! int[] subtypes = types[i].sqlTypes(pi); ! for ( int j=0; j<subtypes.length; j++ ) { ! sqlTypes[n++] = subtypes[j]; ! } ! } ! return sqlTypes; ! } ! ! public int getColumnSpan(Mapping pi) throws MappingException { ! int span = 0; ! for ( int i=0; i<types.length; i++ ) { ! span += types[i].getColumnSpan(pi); ! } ! return span; ! } ! ! public ComponentType( ! Class componentClass, ! Type[] types, ! String[] properties, ! int[] joinedFetch, ! Cascades.CascadeStyle[] ! cascade, ! String parentProperty, ! boolean embedded ! ) throws MappingException { ! ! this.componentClass = componentClass; ! this.types = types; ! propertySpan = properties.length; ! getters = new Method[propertySpan]; ! setters = new Method[propertySpan]; ! for ( int i=0; i<properties.length; i++ ) { ! getters[i] = ReflectHelper.getGetterMethod( componentClass, properties[i] ); ! setters[i] = ReflectHelper.getSetterMethod( componentClass, properties[i] ); ! } ! this.parentSetter = (parentProperty==null) ? null : ReflectHelper.getSetterMethod(componentClass, parentProperty); ! this.parentProperty = parentProperty; ! this.propertyNames = properties; ! this.cascade = cascade; ! this.joinedFetch = joinedFetch; ! constructor = ReflectHelper.getDefaultConstructor(componentClass); ! } ! ! public boolean isPersistentCollectionType() { ! return false; ! } ! public final boolean isComponentType() { ! return true; ! } ! public final boolean isEntityType() { ! return false; ! } ! ! public Class returnedClass() { ! return componentClass; ! } ! ! public boolean equals(Object x, Object y) throws HibernateException { ! if (x==y) return true; ! if (x==null || y==null) return false; ! for ( int i=0; i<getters.length; i++ ) { ! try { ! if ( !types[i].equals( getters[i].invoke(x, null), getters[i].invoke(y, null) ) ) return false; ! } ! catch (Exception e) { ! throw new HibernateException( "Could not compare component property values: " + componentClass.getName() ); ! } ! } ! return true; ! } ! ! public boolean isDirty(Object x, Object y, Object owner, SessionFactoryImplementor factory) throws HibernateException { ! if (x==y) return false; ! if (x==null || y==null) return true; ! for ( int i=0; i<getters.length; i++ ) { ! try { ! if ( types[i].isDirty( getters[i].invoke(x, null), getters[i].invoke(y, null), owner, factory ) ) return true; ! } ! catch (Exception e) { ! throw new HibernateException( "Could not compare component property values: " + componentClass.getName() ); ! } ! } ! return false; ! } ! ! public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) ! throws HibernateException, SQLException { ! ! int begin=0; ! boolean notNull=false; ! Object[] values = new Object[propertySpan]; ! for ( int i=0; i<propertySpan; i++ ) { ! int length = types[i].getColumnSpan( session.getFactory() ); ! String[] range = ArrayHelper.slice(names, begin, length); //cache this ! Object val = types[i].nullSafeGet(rs, range, session, owner); ! if (val!=null) notNull=true; ! values[i] = val; ! begin+=length; ! } ! ! if (notNull) { ! Object result = instantiate(owner); ! for ( int i=0; i<propertySpan; i++ ) { ! ReflectHelper.set( setters[i], result, values[i], componentClass, propertyNames[i] ); ! } ! return result; ! } ! else { ! return null; ! } ! } ! ! public void nullSafeSet(PreparedStatement st, Object value, int begin, SessionImplementor session) ! throws HibernateException, SQLException { ! ! Object[] subvalues = nullSafeGetValues(value); ! ! for ( int i=0; i<propertySpan; i++ ) { ! types[i].nullSafeSet(st, subvalues[i], begin, session); ! begin += types[i].getColumnSpan( session.getFactory() ); ! } ! } ! ! private Object[] nullSafeGetValues(Object value) throws HibernateException { ! if ( value==null ) { ! return new Object[propertySpan]; ! } ! else { ! return getPropertyValues(value); ! } ! } ! ! public Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner) ! throws HibernateException, SQLException { ! ! return nullSafeGet(rs, new String[] {name}, session, owner); ! } ! ! public Object getPropertyValue(Object component, int i) throws HibernateException { ! return ReflectHelper.get( getters[i], component, componentClass, propertyNames[i] ); ! } ! ! public Object[] getPropertyValues(Object component) throws HibernateException { ! Object[] values = new Object[propertySpan]; ! for ( int i=0; i<propertySpan; i++ ) { ! values[i] = getPropertyValue(component, i); ! } ! return values; ! } ! ! public void setPropertyValues(Object component, Object[] values) throws HibernateException { ! for ( int i=0; i<propertySpan; i++ ) { ! ReflectHelper.set( setters[i], component, values[i], componentClass, propertyNames[i] ); ! } ! } ! public Type[] getSubtypes() { ! return types; ! } ! public String getName() { return componentClass.getName(); } ! public String toXML(Object value, SessionFactoryImplementor factory) { ! return (value==null) ? null : value.toString(); ! } ! public String[] getPropertyNames() { ! return propertyNames; ! } ! ! public Object deepCopy(Object component) throws HibernateException { ! if (component==null) return null; ! ! Object[] values = getPropertyValues(component); ! for ( int i=0; i<propertySpan; i++ ) { ! values[i] = types[i].deepCopy( values[i] ); ! } ! Object result = instantiate(null); //TODO: note that this doesn't copy reference to parent. Is that okay?? ! setPropertyValues(result, values); ! return result; ! } ! ! public Object instantiate(Object parent) throws HibernateException { ! try { ! Object inst = constructor.newInstance(null); ! if (parentSetter!=null) ReflectHelper.set(parentSetter, inst, parent, componentClass, parentProperty); ! return inst; ! } ! catch (Exception e) { ! throw new InstantiationException("Could not instantiate component ", componentClass, e); ! } ! } ! ! public Cascades.CascadeStyle cascade(int i) { ! return cascade[i]; ! } ! ! public boolean isMutable() { ! return true; ! } ! ! public Serializable disassemble(Object value, SessionImplementor session) ! throws HibernateException { ! ! if (value==null) { ! return null; ! } ! else { ! Object[] values = getPropertyValues(value); ! for ( int i=0; i<types.length; i++ ) { ! values[i] = types[i].disassemble(values[i], session); ! } ! return values; ! } ! } ! ! public Object assemble(Serializable object, SessionImplementor session, Object owner) throws HibernateException, SQLException { ! if ( object==null ) { ! return null; ! } ! else { ! Object[] values = (Object[]) object; ! Object[] assembled = new Object[values.length]; ! for ( int i=0; i<types.length; i++ ) { ! assembled[i] = types[i].assemble( (Serializable) values[i], session, owner ); ! } ! Object result = instantiate(owner); ! setPropertyValues(result, assembled); ! return result; ! } ! } ! ! public boolean hasNiceEquals() { ! return false; ! } ! ! public int enableJoinedFetch(int i) { ! return joinedFetch[i]; ! } ! ! } ! --- 1,278 ---- ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.io.Serializable; ! import java.lang.reflect.Constructor; ! import java.lang.reflect.Method; ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! ! import cirrus.hibernate.HibernateException; ! import cirrus.hibernate.InstantiationException; ! import cirrus.hibernate.MappingException; ! import cirrus.hibernate.engine.Cascades; ! import cirrus.hibernate.engine.Mapping; ! import cirrus.hibernate.engine.SessionFactoryImplementor; ! import cirrus.hibernate.engine.SessionImplementor; ! import cirrus.hibernate.helpers.ArrayHelper; ! import cirrus.hibernate.helpers.ReflectHelper; ! ! public class ComponentType extends AbstractType implements AbstractComponentType { ! ! private final Class componentClass; ! private final Constructor constructor; ! private final Type[] types; ! private final Method[] getters; ! private final Method[] setters; ! private final String[] propertyNames; ! private final Cascades.CascadeStyle[] cascade; ! private final int propertySpan; ! private final int[] joinedFetch; ! private final String parentProperty; ! private final Method parentSetter; ! ! public int[] sqlTypes(Mapping pi) throws MappingException { ! //Not called at runtime so doesn't matter if its slow :) ! int[] sqlTypes = new int[ getColumnSpan(pi) ]; ! int n=0; ! for ( int i=0; i<propertySpan; i++ ) { ! int[] subtypes = types[i].sqlTypes(pi); ! for ( int j=0; j<subtypes.length; j++ ) { ! sqlTypes[n++] = subtypes[j]; ! } ! } ! return sqlTypes; ! } ! ! public int getColumnSpan(Mapping pi) throws MappingException { ! int span = 0; ! for ( int i=0; i<types.length; i++ ) { ! span += types[i].getColumnSpan(pi); ! } ! return span; ! } ! ! public ComponentType( ! Class componentClass, ! Type[] types, ! String[] properties, ! int[] joinedFetch, ! Cascades.CascadeStyle[] ! cascade, ! String parentProperty, ! boolean embedded ! ) throws MappingException { ! ! this.componentClass = componentClass; ! this.types = types; ! propertySpan = properties.length; ! getters = new Method[propertySpan]; ! setters = new Method[propertySpan]; ! for ( int i=0; i<properties.length; i++ ) { ! getters[i] = ReflectHelper.getGetterMethod( componentClass, properties[i] ); ! setters[i] = ReflectHelper.getSetterMethod( componentClass, properties[i] ); ! } ! this.parentSetter = (parentProperty==null) ? null : ReflectHelper.getSetterMethod(componentClass, parentProperty); ! this.parentProperty = parentProperty; ! this.propertyNames = properties; ! this.cascade = cascade; ! this.joinedFetch = joinedFetch; ! constructor = ReflectHelper.getDefaultConstructor(componentClass); ! } ! ! public boolean isPersistentCollectionType() { ! return false; ! } ! public final boolean isComponentType() { ! return true; ! } ! public final boolean isEntityType() { ! return false; ! } ! ! public Class returnedClass() { ! return componentClass; ! } ! ! public boolean equals(Object x, Object y) throws HibernateException { ! if (x==y) return true; ! if (x==null || y==null) return false; ! for ( int i=0; i<getters.length; i++ ) { ! try { ! if ( !types[i].equals( getters[i].invoke(x, null), getters[i].invoke(y, null) ) ) return false; ! } ! catch (Exception e) { ! throw new HibernateException( "Could not compare component property values: " + componentClass.getName() ); ! } ! } ! return true; ! } ! ! public boolean isDirty(Object x, Object y, Object owner, SessionFactoryImplementor factory) throws HibernateException { ! if (x==y) return false; ! if (x==null || y==null) return true; ! for ( int i=0; i<getters.length; i++ ) { ! try { ! if ( types[i].isDirty( getters[i].invoke(x, null), getters[i].invoke(y, null), owner, factory ) ) return true; ! } ! catch (Exception e) { ! throw new HibernateException( "Could not compare component property values: " + componentClass.getName() ); ! } ! } ! return false; ! } ! ! public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) ! throws HibernateException, SQLException { ! ! int begin=0; ! boolean notNull=false; ! Object[] values = new Object[propertySpan]; ! for ( int i=0; i<propertySpan; i++ ) { ! int length = types[i].getColumnSpan( session.getFactory() ); ! String[] range = ArrayHelper.slice(names, begin, length); //cache this ! Object val = types[i].nullSafeGet(rs, range, session, owner); ! if (val!=null) notNull=true; ! values[i] = val; ! begin+=length; ! } ! ! if (notNull) { ! Object result = instantiate(owner); ! for ( int i=0; i<propertySpan; i++ ) { ! ReflectHelper.set( setters[i], result, values[i], componentClass, propertyNames[i] ); ! } ! return result; ! } ! else { ! return null; ! } ! } ! ! public void nullSafeSet(PreparedStatement st, Object value, int begin, SessionImplementor session) ! throws HibernateException, SQLException { ! ! Object[] subvalues = nullSafeGetValues(value); ! ! for ( int i=0; i<propertySpan; i++ ) { ! types[i].nullSafeSet(st, subvalues[i], begin, session); ! begin += types[i].getColumnSpan( session.getFactory() ); ! } ! } ! ! private Object[] nullSafeGetValues(Object value) throws HibernateException { ! if ( value==null ) { ! return new Object[propertySpan]; ! } ! else { ! return getPropertyValues(value); ! } ! } ! ! public Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner) ! throws HibernateException, SQLException { ! ! return nullSafeGet(rs, new String[] {name}, session, owner); ! } ! ! public Object getPropertyValue(Object component, int i) throws HibernateException { ! return ReflectHelper.get( getters[i], component, componentClass, propertyNames[i] ); ! } ! ! public Object[] getPropertyValues(Object component) throws HibernateException { ! Object[] values = new Object[propertySpan]; ! for ( int i=0; i<propertySpan; i++ ) { ! values[i] = getPropertyValue(component, i); ! } ! return values; ! } ! ! public void setPropertyValues(Object component, Object[] values) throws HibernateException { ! for ( int i=0; i<propertySpan; i++ ) { ! ReflectHelper.set( setters[i], component, values[i], componentClass, propertyNames[i] ); ! } ! } ! public Type[] getSubtypes() { ! return types; ! } ! public String getName() { return componentClass.getName(); } ! public String toXML(Object value, SessionFactoryImplementor factory) { ! return (value==null) ? null : value.toString(); ! } ! public String[] getPropertyNames() { ! return propertyNames; ! } ! ! public Object deepCopy(Object component) throws HibernateException { ! if (component==null) return null; ! ! Object[] values = getPropertyValues(component); ! for ( int i=0; i<propertySpan; i++ ) { ! values[i] = types[i].deepCopy( values[i] ); ! } ! Object result = instantiate(null); //TODO: note that this doesn't copy reference to parent. Is that okay?? ! setPropertyValues(result, values); ! return result; ! } ! ! public Object instantiate(Object parent) throws HibernateException { ! try { ! Object inst = constructor.newInstance(null); ! if (parentSetter!=null) ReflectHelper.set(parentSetter, inst, parent, componentClass, parentProperty); ! return inst; ! } ! catch (Exception e) { ! throw new InstantiationException("Could not instantiate component ", componentClass, e); ! } ! } ! ! public Cascades.CascadeStyle cascade(int i) { ! return cascade[i]; ! } ! ! public boolean isMutable() { ! return true; ! } ! ! public Serializable disassemble(Object value, SessionImplementor session) ! throws HibernateException { ! ! if (value==null) { ! return null; ! } ! else { ! Object[] values = getPropertyValues(value); ! for ( int i=0; i<types.length; i++ ) { ! values[i] = types[i].disassemble(values[i], session); ! } ! return values; ! } ! } ! ! public Object assemble(Serializable object, SessionImplementor session, Object owner) throws HibernateException, SQLException { ! if ( object==null ) { ! return null; ! } ! else { ! Object[] values = (Object[]) object; ! Object[] assembled = new Object[values.length]; ! for ( int i=0; i<types.length; i++ ) { ! assembled[i] = types[i].assemble( (Serializable) values[i], session, owner ); ! } ! Object result = instantiate(owner); ! setPropertyValues(result, assembled); ! return result; ! } ! } ! ! public boolean hasNiceEquals() { ! return false; ! } ! ! public int enableJoinedFetch(int i) { ! return joinedFetch[i]; ! } ! ! } ! Index: CurrencyType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/CurrencyType.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CurrencyType.java 28 Oct 2002 15:41:53 -0000 1.5 --- CurrencyType.java 26 Nov 2002 03:35:45 -0000 1.6 *************** *** 1,131 **** ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.lang.reflect.Method; ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! ! import cirrus.hibernate.AssertionFailure; ! import cirrus.hibernate.Hibernate; ! import cirrus.hibernate.HibernateException; ! ! /** ! * A type for <tt>java.util.Currency</tt> ! * @see java.util.Currency ! */ ! public class CurrencyType extends ImmutableType implements LiteralType { ! ! public static final Class CURRENCY_CLASS; ! private static final Method CURRENCY_GET_INSTANCE; ! private static final Method CURRENCY_GET_CODE; ! ! static { ! Class clazz; ! try { ! clazz = Class.forName("java.util.Currency"); ! } ! catch (ClassNotFoundException cnfe) { ! clazz = null; ! } ! if (clazz==null) { ! CURRENCY_CLASS = null; ! CURRENCY_GET_INSTANCE = null; ! CURRENCY_GET_CODE = null; ! } ! else { ! CURRENCY_CLASS = clazz; ! try { ! CURRENCY_GET_INSTANCE = clazz.getMethod("getInstance", new Class[] { String.class } ); ! CURRENCY_GET_CODE = clazz.getMethod("getCurrencyCode", new Class[0] ); ! } ! catch (Exception e) { ! throw new AssertionFailure("Exception in static initializer of CurrencyType", e); ! } ! } ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#get(ResultSet, String) ! */ ! public Object get(ResultSet rs, String name) ! throws HibernateException, SQLException { ! String code = (String) Hibernate.STRING.nullSafeGet(rs, name); ! try { ! return (code==null) ? null : CURRENCY_GET_INSTANCE.invoke(null, new Object[] { code } ); ! } ! catch (Exception e) { ! throw new HibernateException("Could not resolve currency code: " + code); ! } ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#set(PreparedStatement, Object, int) ! */ ! public void set(PreparedStatement st, Object value, int index) ! throws HibernateException, SQLException { ! Object code; ! try { ! code = CURRENCY_GET_CODE.invoke(value, null); ! } ! catch (Exception e) { ! throw new HibernateException("Could not get Currency code", e); ! } ! Hibernate.STRING.set(st, code, index); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#sqlType() ! */ ! public int sqlType() { ! return Hibernate.STRING.sqlType(); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#toXML(Object) ! */ ! public String toXML(Object value) throws HibernateException { ! try { ! return (String) CURRENCY_GET_CODE.invoke(value, null); ! } ! catch (Exception e) { ! throw new HibernateException("Could not get Currency code", e); ! } ! } ! ! /** ! * @see cirrus.hibernate.type.Type#returnedClass() ! */ ! public Class returnedClass() { ! return CURRENCY_CLASS; ! } ! ! /** ! * @see cirrus.hibernate.type.Type#equals(Object, Object) ! */ ! public boolean equals(Object x, Object y) throws HibernateException { ! return x==y || ( x!=null && y!=null && x.equals(y) ); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#getName() ! */ ! public String getName() { ! return "currency"; ! } ! ! /** ! * @see cirrus.hibernate.type.LiteralType#objectToSQLString(Object) ! */ ! public String objectToSQLString(Object value) throws Exception { ! String code; ! try { ! code = (String) CURRENCY_GET_CODE.invoke(value, null); ! } ! catch (Exception e) { ! throw new HibernateException("Could not get Currency code", e); ! } ! return ( (LiteralType) Hibernate.STRING ).objectToSQLString(code); ! } ! ! } --- 1,131 ---- ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.lang.reflect.Method; ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! ! import cirrus.hibernate.AssertionFailure; ! import cirrus.hibernate.Hibernate; ! import cirrus.hibernate.HibernateException; ! ! /** ! * A type for <tt>java.util.Currency</tt> ! * @see java.util.Currency ! */ ! public class CurrencyType extends ImmutableType implements LiteralType { ! ! public static final Class CURRENCY_CLASS; ! private static final Method CURRENCY_GET_INSTANCE; ! private static final Method CURRENCY_GET_CODE; ! ! static { ! Class clazz; ! try { ! clazz = Class.forName("java.util.Currency"); ! } ! catch (ClassNotFoundException cnfe) { ! clazz = null; ! } ! if (clazz==null) { ! CURRENCY_CLASS = null; ! CURRENCY_GET_INSTANCE = null; ! CURRENCY_GET_CODE = null; ! } ! else { ! CURRENCY_CLASS = clazz; ! try { ! CURRENCY_GET_INSTANCE = clazz.getMethod("getInstance", new Class[] { String.class } ); ! CURRENCY_GET_CODE = clazz.getMethod("getCurrencyCode", new Class[0] ); ! } ! catch (Exception e) { ! throw new AssertionFailure("Exception in static initializer of CurrencyType", e); ! } ! } ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#get(ResultSet, String) ! */ ! public Object get(ResultSet rs, String name) ! throws HibernateException, SQLException { ! String code = (String) Hibernate.STRING.nullSafeGet(rs, name); ! try { ! return (code==null) ? null : CURRENCY_GET_INSTANCE.invoke(null, new Object[] { code } ); ! } ! catch (Exception e) { ! throw new HibernateException("Could not resolve currency code: " + code); ! } ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#set(PreparedStatement, Object, int) ! */ ! public void set(PreparedStatement st, Object value, int index) ! throws HibernateException, SQLException { ! Object code; ! try { ! code = CURRENCY_GET_CODE.invoke(value, null); ! } ! catch (Exception e) { ! throw new HibernateException("Could not get Currency code", e); ! } ! Hibernate.STRING.set(st, code, index); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#sqlType() ! */ ! public int sqlType() { ! return Hibernate.STRING.sqlType(); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#toXML(Object) ! */ ! public String toXML(Object value) throws HibernateException { ! try { ! return (String) CURRENCY_GET_CODE.invoke(value, null); ! } ! catch (Exception e) { ! throw new HibernateException("Could not get Currency code", e); ! } ! } ! ! /** ! * @see cirrus.hibernate.type.Type#returnedClass() ! */ ! public Class returnedClass() { ! return CURRENCY_CLASS; ! } ! ! /** ! * @see cirrus.hibernate.type.Type#equals(Object, Object) ! */ ! public boolean equals(Object x, Object y) throws HibernateException { ! return x==y || ( x!=null && y!=null && x.equals(y) ); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#getName() ! */ ! public String getName() { ! return "currency"; ! } ! ! /** ! * @see cirrus.hibernate.type.LiteralType#objectToSQLString(Object) ! */ ! public String objectToSQLString(Object value) throws Exception { ! String code; ! try { ! code = (String) CURRENCY_GET_CODE.invoke(value, null); ! } ! catch (Exception e) { ! throw new HibernateException("Could not get Currency code", e); ! } ! return ( (LiteralType) Hibernate.STRING ).objectToSQLString(code); ! } ! ! } Index: DoubleType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/DoubleType.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** DoubleType.java 28 Oct 2002 15:41:53 -0000 1.10 --- DoubleType.java 26 Nov 2002 03:35:45 -0000 1.11 *************** *** 1,5 **** ! //$Id$ package cirrus.hibernate.type; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; ! public class DoubleType extends PrimitiveType { public Object get(ResultSet rs, String name) throws SQLException { --- 1,5 ---- ! //$Id$ package cirrus.hibernate.type; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; ! public class DoubleType extends PrimitiveType { public Object get(ResultSet rs, String name) throws SQLException { Index: IdentifierType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/IdentifierType.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IdentifierType.java 6 Sep 2002 17:03:00 -0000 1.3 --- IdentifierType.java 26 Nov 2002 03:35:46 -0000 1.4 *************** *** 1,16 **** ! //$Id$ ! package cirrus.hibernate.type; ! ! /** ! * A <tt>Type</tt> that may be used as an identifier. ! */ ! public interface IdentifierType extends Type { ! /** ! * Convert the value from the mapping file to a Java object. ! * @param xml the value of <tt>discriminator-value</tt> or <tt>unsaved-value</tt> attribute ! * @return Object ! * @throws Exception ! */ ! public Object stringToObject(String xml) throws Exception; ! ! } --- 1,16 ---- ! //$Id$ ! package cirrus.hibernate.type; ! ! /** ! * A <tt>Type</tt> that may be used as an identifier. ! */ ! public interface IdentifierType extends Type { ! /** ! * Convert the value from the mapping file to a Java object. ! * @param xml the value of <tt>discriminator-value</tt> or <tt>unsaved-value</tt> attribute ! * @return Object ! * @throws Exception ! */ ! public Object stringToObject(String xml) throws Exception; ! ! } Index: LiteralType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/LiteralType.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LiteralType.java 28 Oct 2002 15:44:38 -0000 1.1 --- LiteralType.java 26 Nov 2002 03:35:46 -0000 1.2 *************** *** 1,17 **** ! //$Id$ ! package cirrus.hibernate.type; ! ! /** ! * A type that may appear as an SQL literal ! */ ! public interface LiteralType { ! /** ! * String representation of the value, suitable for embedding in ! * an SQL statement. ! * @param value ! * @return String ! * @throws Exception ! */ ! public String objectToSQLString(Object value) throws Exception; ! ! } --- 1,17 ---- ! //$Id$ ! package cirrus.hibernate.type; ! ! /** ! * A type that may appear as an SQL literal ! */ ! public interface LiteralType { ! /** ! * String representation of the value, suitable for embedding in ! * an SQL statement. ! * @param value ! * @return String ! * @throws Exception ! */ ! public String objectToSQLString(Object value) throws Exception; ! ! } Index: TimeZoneType.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate/cirrus/hibernate/type/TimeZoneType.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TimeZoneType.java 28 Oct 2002 15:41:53 -0000 1.2 --- TimeZoneType.java 26 Nov 2002 03:35:46 -0000 1.3 *************** *** 1,79 **** ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! import java.util.TimeZone; ! ! import cirrus.hibernate.Hibernate; ! import cirrus.hibernate.HibernateException; ! ! /** ! * A type for <tt>java.util.TimeZone</tt> ! * @see java.util.TimeZone ! */ ! public class TimeZoneType extends ImmutableType implements LiteralType { ! ! /** ! * @see cirrus.hibernate.type.NullableType#get(ResultSet, String) ! */ ! public Object get(ResultSet rs, String name) ! throws HibernateException, SQLException { ! String id = (String) Hibernate.STRING.nullSafeGet(rs, name); ! return (id==null) ? null : TimeZone.getTimeZone(id); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#set(PreparedStatement, Object, int) ! */ ! public void set(PreparedStatement st, Object value, int index) ! throws HibernateException, SQLException { ! Hibernate.STRING.set(st, ( (TimeZone) value ).getID(), index); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#sqlType() ! */ ! public int sqlType() { ! return Hibernate.STRING.sqlType(); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#toXML(Object) ! */ ! public String toXML(Object value) throws HibernateException { ! return ( (TimeZone) value ).getID(); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#returnedClass() ! */ ! public Class returnedClass() { ! return TimeZone.class; ! } ! ! /** ! * @see cirrus.hibernate.type.Type#equals(Object, Object) ! */ ! public boolean equals(Object x, Object y) throws HibernateException { ! return x==y || ( x!=null && y!=null && x.equals(y) ); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#getName() ! */ ! public String getName() { ! return "timezone"; ! } ! ! /** ! * @see cirrus.hibernate.type.LiteralType#objectToSQLString(Object) ! */ ! public String objectToSQLString(Object value) throws Exception { ! return ( (LiteralType) Hibernate.STRING ).objectToSQLString( ! ( (TimeZone) value ).getID() ! ); ! } ! ! } --- 1,79 ---- ! //$Id$ ! package cirrus.hibernate.type; ! ! import java.sql.PreparedStatement; ! import java.sql.ResultSet; ! import java.sql.SQLException; ! import java.util.TimeZone; ! ! import cirrus.hibernate.Hibernate; ! import cirrus.hibernate.HibernateException; ! ! /** ! * A type for <tt>java.util.TimeZone</tt> ! * @see java.util.TimeZone ! */ ! public class TimeZoneType extends ImmutableType implements LiteralType { ! ! /** ! * @see cirrus.hibernate.type.NullableType#get(ResultSet, String) ! */ ! public Object get(ResultSet rs, String name) ! throws HibernateException, SQLException { ! String id = (String) Hibernate.STRING.nullSafeGet(rs, name); ! return (id==null) ? null : TimeZone.getTimeZone(id); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#set(PreparedStatement, Object, int) ! */ ! public void set(PreparedStatement st, Object value, int index) ! throws HibernateException, SQLException { ! Hibernate.STRING.set(st, ( (TimeZone) value ).getID(), index); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#sqlType() ! */ ! public int sqlType() { ! return Hibernate.STRING.sqlType(); ! } ! ! /** ! * @see cirrus.hibernate.type.NullableType#toXML(Object) ! */ ! public String toXML(Object value) throws HibernateException { ! return ( (TimeZone) value ).getID(); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#returnedClass() ! */ ! public Class returnedClass() { ! return TimeZone.class; ! } ! ! /** ! * @see cirrus.hibernate.type.Type#equals(Object, Object) ! */ ! public boolean equals(Object x, Object y) throws HibernateException { ! return x==y || ( x!=null && y!=null && x.equals(y) ); ! } ! ! /** ! * @see cirrus.hibernate.type.Type#getName() ! */ ! public String getName() { ! return "timezone"; ! } ! ! /** ! * @see cirrus.hibernate.type.LiteralType#objectToSQLString(Object) ! */ ! public String objectToSQLString(Object value) throws Exception { ! return ( (LiteralType) Hibernate.STRING ).objectToSQLString( ! ( (TimeZone) value ).getID() ! ); ! } ! ! } |