org.hibernate.type
Class AbstractBynaryType

java.lang.Object
  extended by org.hibernate.type.AbstractType
      extended by org.hibernate.type.NullableType
          extended by org.hibernate.type.MutableType
              extended by org.hibernate.type.AbstractBynaryType
All Implemented Interfaces:
Serializable, Comparator, Type, VersionType
Direct Known Subclasses:
BinaryType, WrapperBinaryType

public abstract class AbstractBynaryType
extends MutableType
implements VersionType, Comparator

Logic to bind stream of byte into a VARBINARY

Author:
Gavin King, Emmanuel Bernard
See Also:
Serialized Form

Constructor Summary
AbstractBynaryType()
           
 
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)
          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"
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)
          Set a parameter value without worrying about the possibility of null values.
 int sqlType()
          A convenience form of NullableType.sqlTypes(org.hibernate.engine.Mapping), returning just a single type value since these are explicitly dealing with single column mappings.
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, isMutable, replace
 
Methods inherited from class org.hibernate.type.NullableType
fromXMLNode, fromXMLString, getColumnSpan, isDirty, isEqual, nullSafeGet, nullSafeGet, nullSafeGet, nullSafeGet, nullSafeSet, nullSafeSet, nullSafeSet, nullSafeToString, setToXMLNode, sqlTypes, toColumnNullness, toLoggableString, toXMLString
 
Methods inherited from class org.hibernate.type.AbstractType
assemble, beforeAssemble, disassemble, getHashCode, getSemiResolvedType, hydrate, isAnyType, isAssociationType, isCollectionType, isComponentType, isDirty, isEntityType, isEqual, isModified, isSame, isXMLElement, replace, replaceNode, resolve, semiResolve
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.hibernate.type.Type
assemble, beforeAssemble, deepCopy, disassemble, fromXMLNode, getColumnSpan, getHashCode, getReturnedClass, getSemiResolvedType, hydrate, isAnyType, isAssociationType, isCollectionType, isComponentType, isDirty, isDirty, isEntityType, isEqual, isEqual, isModified, isMutable, isSame, isXMLElement, nullSafeGet, nullSafeGet, nullSafeSet, nullSafeSet, replace, replace, resolve, semiResolve, setToXMLNode, sqlTypes, toColumnNullness, toLoggableString
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

AbstractBynaryType

public AbstractBynaryType()
Method Detail

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


set

public void set(PreparedStatement st,
                Object value,
                int index)
         throws HibernateException,
                SQLException
Description copied from class: NullableType
Set a parameter value without worrying about the possibility of null values. Called from NullableType.nullSafeSet(java.sql.PreparedStatement, java.lang.Object, int, boolean[], org.hibernate.engine.SessionImplementor) after nullness checks have been performed.

Specified by:
set in class 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.
SQLException - Indicates problem making the JDBC call(s).

get

public Object get(ResultSet rs,
                  String name)
           throws HibernateException,
                  SQLException
Description copied from class: NullableType
Get a column value from a result set, without worrying about the possibility of null values. Called from NullableType.nullSafeGet(java.sql.ResultSet, java.lang.String[], org.hibernate.engine.SessionImplementor, java.lang.Object) after nullness checks have been performed.

Specified by:
get in class 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.
SQLException - Indicates problem making the JDBC call(s).

sqlType

public int sqlType()
Description copied from class: NullableType
A convenience form of NullableType.sqlTypes(org.hibernate.engine.Mapping), returning just a single type value since these are explicitly dealing with single column mappings.

Specified by:
sqlType in class NullableType
Returns:
The Types mapping value.

seed

public Object seed(SessionImplementor session)
Description copied from interface: VersionType
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

next

public Object next(Object current,
                   SessionImplementor session)
Description copied from interface: VersionType
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

getComparator

public Comparator getComparator()
Description copied from interface: VersionType
Get a comparator for version values.

Specified by:
getComparator in interface VersionType
Returns:
The comparator to use to compare different version values.

compare

public int compare(Object o1,
                   Object o2)
Specified by:
compare in interface Comparator

isEqual

public boolean isEqual(Object x,
                       Object y)
Description copied from interface: VersionType
Are the two version values considered equal?

Specified by:
isEqual in interface VersionType
Overrides:
isEqual in class NullableType
Parameters:
x - One value to check.
y - The other value to check.
Returns:
true if the values are equal, false otherwise.

getHashCode

public int getHashCode(Object x,
                       EntityMode entityMode)
Description copied from interface: Type
Get a hashcode, consistent with persistence "equality"

Specified by:
getHashCode in interface Type
Overrides:
getHashCode in class AbstractType

compare

public int compare(Object x,
                   Object y,
                   EntityMode entityMode)
Description copied from interface: Type
compare two instances of the type

Specified by:
compare in interface Type
Overrides:
compare in class AbstractType

getName

public abstract String getName()
Description copied from interface: Type
Returns the abbreviated name of the type.

Specified by:
getName in interface Type
Returns:
String the Hibernate type name

toString

public String toString(Object val)
Specified by:
toString in class NullableType

deepCopyNotNull

public Object deepCopyNotNull(Object value)
Specified by:
deepCopyNotNull in class MutableType

fromStringValue

public Object fromStringValue(String xml)
                       throws HibernateException
Specified by:
fromStringValue in class NullableType
Throws:
HibernateException


Copyright © 2009 Hibernate.org. All Rights Reserved.