org.hibernate.type

Class CalendarType

Implemented Interfaces:
Serializable, Type, VersionType

public class CalendarType
extends MutableType
implements VersionType

calendar: A type mapping for a Calendar object that represents a datetime.
Author:
Gavin King

Method Summary

int
compare(Object x, Object y, EntityMode entityMode)
compare two instances of the type
Object
deepCopyNotNull(Object value)
Object
fromStringValue(String xml)
Object
get(ResultSet rs, String name)
Get a column value from a result set, without worrying about the possibility of null values.
Comparator
getComparator()
Get a comparator for version values.
int
getHashCode(Object x, EntityMode entityMode)
Get a hashcode, consistent with persistence "equality"
String
getName()
Returns the abbreviated name of the type.
Class
getReturnedClass()
The class returned by nullSafeGet() methods.
boolean
isEqual(Object x, Object y)
Are the two version values considered equal?
Object
next(Object current, SessionImplementor session)
Increment the version.
Object
seed(SessionImplementor session)
Generate an initial version.
void
set(PreparedStatement st, Object value, int index)
Set a parameter value without worrying about the possibility of null values.
int
sqlType()
A convenience form of NullableType.sqlTypes(Mapping), returning just a single type value since these are explicitly dealing with single column mappings.
String
toString(Object value)

Methods inherited from class org.hibernate.type.MutableType

deepCopy, deepCopyNotNull, isMutable, replace

Methods inherited from class org.hibernate.type.NullableType

fromStringValue, fromXMLNode, fromXMLString, get, getColumnSpan, isDirty, isEqual, isEqual, nullSafeGet, nullSafeGet, nullSafeGet, nullSafeGet, nullSafeSet, nullSafeSet, nullSafeSet, nullSafeToString, set, setToXMLNode, sqlType, sqlTypes, toColumnNullness, toLoggableString, toString, toXMLString

Methods inherited from class org.hibernate.type.AbstractType

assemble, beforeAssemble, compare, disassemble, getHashCode, getHashCode, getSemiResolvedType, hydrate, isAnyType, isAssociationType, isCollectionType, isComponentType, isDirty, isEntityType, isEqual, isEqual, isModified, isSame, isXMLElement, replace, replaceNode, resolve, semiResolve

Method Details

compare

public int compare(Object x,
                   Object y,
                   EntityMode entityMode)
compare two instances of the type
Specified by:
compare in interface Type
Overrides:
compare in interface AbstractType
Parameters:
entityMode -

deepCopyNotNull

public Object deepCopyNotNull(Object value)
            throws HibernateException
Overrides:
deepCopyNotNull in interface MutableType

fromStringValue

public Object fromStringValue(String xml)
            throws HibernateException
Overrides:
fromStringValue in interface NullableType

get

public Object get(ResultSet rs,
                  String name)
            throws HibernateException,
                   SQLException
Get a column value from a result set, without worrying about the possibility of null values. Called from nullSafeGet after nullness checks have been performed.
Overrides:
get in interface NullableType
Parameters:
rs - The result set from which to extract the value.
name - The name of the value to extract.
Returns:
The extracted value.
Throws:
HibernateException - Generally some form of mismatch error.

getComparator

public Comparator getComparator()
Get a comparator for version values.
Specified by:
getComparator in interface VersionType
Returns:
The comparator to use to compare different version values.

getHashCode

public int getHashCode(Object x,
                       EntityMode entityMode)
Get a hashcode, consistent with persistence "equality"
Specified by:
getHashCode in interface Type
Overrides:
getHashCode in interface AbstractType
Parameters:
x -
entityMode -

getName

public String getName()
Returns the abbreviated name of the type.
Specified by:
getName in interface Type
Returns:
String the Hibernate type name

getReturnedClass

public Class getReturnedClass()
The class returned by nullSafeGet() methods. This is used to establish the class of an array of this type.
Specified by:
getReturnedClass in interface Type
Returns:
Class

isEqual

public boolean isEqual(Object x,
                       Object y)
Are the two version values considered equal?
Specified by:
isEqual in interface VersionType
Overrides:
isEqual in interface NullableType
Parameters:
x - One value to check.
y - The other value to check.
Returns:
true if the values are equal, false otherwise.

next

public Object next(Object current,
                   SessionImplementor session)
Increment the version.
Specified by:
next in interface VersionType
Parameters:
current - the current version
session - The session from which this request originates.
Returns:
an instance of the type

seed

public Object seed(SessionImplementor session)
Generate an initial version.
Specified by:
seed in interface VersionType
Parameters:
session - The session from which this request originates.
Returns:
an instance of the type

set

public void set(PreparedStatement st,
                Object value,
                int index)
            throws HibernateException,
                   SQLException
Set a parameter value without worrying about the possibility of null values. Called from nullSafeSet after nullness checks have been performed.
Overrides:
set in interface NullableType
Parameters:
st - The statement into which to bind the parameter value.
value - The parameter value to bind.
index - The position or index at which to bind the param value.
Throws:
HibernateException - Generally some form of mismatch error.

sqlType

public int sqlType()
A convenience form of NullableType.sqlTypes(Mapping), returning just a single type value since these are explicitly dealing with single column mappings.
Overrides:
sqlType in interface NullableType
Returns:
The java.sql.Types mapping value.

toString

public String toString(Object value)
            throws HibernateException
Overrides:
toString in interface NullableType