FileDocCategorySizeDatePackage
CalendarType.javaAPI DocHibernate 3.2.53826Wed Aug 03 15:03:34 BST 2005org.hibernate.type

CalendarType

public class CalendarType extends MutableType implements VersionType
calendar: A type mapping for a Calendar object that represents a datetime.
author
Gavin King

Fields Summary
Constructors Summary
Methods Summary
public intcompare(java.lang.Object x, java.lang.Object y, org.hibernate.EntityMode entityMode)

		return CalendarComparator.INSTANCE.compare(x, y);
	
public java.lang.ObjectdeepCopyNotNull(java.lang.Object value)

		return ( (Calendar) value ).clone();
	
public java.lang.ObjectfromStringValue(java.lang.String xml)

		Calendar result = new GregorianCalendar();
		result.setTime( ( (Date) Hibernate.TIMESTAMP.fromStringValue(xml) ) );
		return result;
	
public java.lang.Objectget(java.sql.ResultSet rs, java.lang.String name)


		Timestamp ts = rs.getTimestamp(name);
		if (ts!=null) {
			Calendar cal = new GregorianCalendar();
			if ( Environment.jvmHasTimestampBug() ) {
				cal.setTime( new Date( ts.getTime() + ts.getNanos() / 1000000 ) );
			}
			else {
				cal.setTime(ts);
			}
			return cal;
		}
		else {
			return null;
		}

	
public java.util.ComparatorgetComparator()

		return CalendarComparator.INSTANCE;
	
public intgetHashCode(java.lang.Object x, org.hibernate.EntityMode entityMode)

		Calendar calendar = (Calendar) x;
		int hashCode = 1;
		hashCode = 31 * hashCode + calendar.get(Calendar.MILLISECOND);
		hashCode = 31 * hashCode + calendar.get(Calendar.SECOND);
		hashCode = 31 * hashCode + calendar.get(Calendar.MINUTE);
		hashCode = 31 * hashCode + calendar.get(Calendar.HOUR_OF_DAY);
		hashCode = 31 * hashCode + calendar.get(Calendar.DAY_OF_MONTH);
		hashCode = 31 * hashCode + calendar.get(Calendar.MONTH);
		hashCode = 31 * hashCode + calendar.get(Calendar.YEAR);
		return hashCode;
	
public java.lang.StringgetName()

		return "calendar";
	
public java.lang.ClassgetReturnedClass()

		return Calendar.class;
	
public booleanisEqual(java.lang.Object x, java.lang.Object y)

		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);
	
public java.lang.Objectnext(java.lang.Object current, org.hibernate.engine.SessionImplementor session)

		return seed( session );
	
public java.lang.Objectseed(org.hibernate.engine.SessionImplementor session)

		return Calendar.getInstance();
	
public voidset(java.sql.PreparedStatement st, java.lang.Object value, int index)

		final Calendar cal = (Calendar) value;
		//st.setTimestamp( index,  new Timestamp( cal.getTimeInMillis() ), cal ); //JDK 1.5 only
		st.setTimestamp( index,  new Timestamp( cal.getTime().getTime() ), cal );
	
public intsqlType()

		return Types.TIMESTAMP;
	
public java.lang.StringtoString(java.lang.Object value)

		return Hibernate.TIMESTAMP.toString( ( (Calendar) value ).getTime() );