FileDocCategorySizeDatePackage
CalendarDateType.javaAPI DocHibernate 3.2.52665Mon Dec 05 21:34:24 GMT 2005org.hibernate.type

CalendarDateType

public class CalendarDateType extends MutableType
calendar_date: A type mapping for a Calendar object that represents a date.
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( ( (java.util.Date) Hibernate.DATE.fromStringValue(xml) ) );
		return result;
	
public java.lang.Objectget(java.sql.ResultSet rs, java.lang.String name)


		Date date = rs.getDate(name);
		if (date!=null) {
			Calendar cal = new GregorianCalendar();
			cal.setTime(date);
			return cal;
		}
		else {
			return null;
		}

	
public intgetHashCode(java.lang.Object x, org.hibernate.EntityMode entityMode)

		Calendar calendar = (Calendar) x;
		int hashCode = 1;
		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_date";
	
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.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 voidset(java.sql.PreparedStatement st, java.lang.Object value, int index)

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

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

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