org.hibernate.type

Class AbstractBynaryType

Implemented Interfaces:
Comparator, Serializable, Type, VersionType
Known Direct Subclasses:
BinaryType, WrapperBinaryType

public abstract class AbstractBynaryType
extends MutableType
implements VersionType, Comparator

Logic to bind stream of byte into a VARBINARY
Authors:
Gavin King
Emmanuel Bernard

Method Summary

int
compare(Object o1, Object o2)
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)
Comparator
getComparator()
Get a comparator for version values.
int
getHashCode(Object x, EntityMode entityMode)
Get a hashcode, consistent with persistence "equality"
abstract String
getName()
Returns the abbreviated name of the type.
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)
int
sqlType()
protected abstract Object
toExternalFormat(byte[] bytes)
Convert the byte[] into the expected object type
protected abstract byte[]
toInternalFormat(Object bytes)
Convert the object into the internal byte[] representation
String
toString(Object val)

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 o1,
                   Object o2)

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)
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
Overrides:
get in interface NullableType

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 abstract String getName()
Returns the abbreviated name of the type.
Specified by:
getName in interface Type
Returns:
String the Hibernate type name

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
Overrides:
set in interface NullableType

sqlType

public int sqlType()
Overrides:
sqlType in interface NullableType

toExternalFormat

protected abstract Object toExternalFormat(byte[] bytes)
Convert the byte[] into the expected object type

toInternalFormat

protected abstract byte[] toInternalFormat(Object bytes)
Convert the object into the internal byte[] representation

toString

public String toString(Object val)
Overrides:
toString in interface NullableType