站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Hibernate 2.1.8 正式版 API 英文文档

CustomType (Hibernate API Documentation) - Hibernate 2.1.8 正式版 API 英文文档


net.sf.hibernate.type
Class CustomType

java.lang.Object
  extended bynet.sf.hibernate.type.AbstractType
      extended bynet.sf.hibernate.type.CustomType
All Implemented Interfaces:
Serializable, Type

public class CustomType
extends AbstractType

Adapts UserType to the generic Type interface.

Author:
Gavin King
See Also:
UserType, Serialized Form

Constructor Summary
CustomType(Class userTypeClass)
           
 
Method Summary
 Object deepCopy(Object value)
          Return a deep copy of the persistent state, stopping at entities and at collections.
 boolean equals(Object object)
           
 boolean equals(Object x, Object y)
          Compare two instances of the class mapped by this type for persistence "equality", ie.
 Object fromString(String xml)
          Parse the XML representation of an instance.
 int getColumnSpan(Mapping session)
          How many columns are used to persist this type.
 String getName()
          Returns the abbreviated name of the type.
 Class getReturnedClass()
          The class returned by nullSafeGet() methods.
 int hashCode()
           
 boolean hasNiceEquals()
          Does this type implement a well-behaved equals() method.
 boolean isMutable()
          Are objects of this type mutable.
 Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
          Retrieve an instance of the mapped class from a JDBC resultset.
 Object nullSafeGet(ResultSet rs, String columnName, SessionImplementor session, Object owner)
          Retrieve an instance of the mapped class from a JDBC resultset.
 void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
          Write an instance of the mapped class to a prepared statement.
 int[] sqlTypes(Mapping pi)
          Return the SQL type codes for the columns mapped by this type.
 String toString(Object value, SessionFactoryImplementor factory)
          A representation of the value to be embedded in an XML element.
 
Methods inherited from class net.sf.hibernate.type.AbstractType
assemble, copy, disassemble, hydrate, isAssociationType, isComponentType, isDirty, isEntityType, isModified, isObjectType, isPersistentCollectionType, resolveIdentifier
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomType

public CustomType(Class userTypeClass)
           throws MappingException
Method Detail

sqlTypes

public int[] sqlTypes(Mapping pi)
Description copied from interface: Type
Return the SQL type codes for the columns mapped by this type. The codes are defined on java.sql.Types.

Returns:
the typecodes
See Also:
Type.sqlTypes(Mapping)

getColumnSpan

public int getColumnSpan(Mapping session)
Description copied from interface: Type
How many columns are used to persist this type.

See Also:
Type.getColumnSpan(Mapping)

getReturnedClass

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

Returns:
Class
See Also:
Type.getReturnedClass()

equals

public boolean equals(Object x,
                      Object y)
               throws HibernateException
Description copied from interface: Type
Compare two instances of the class mapped by this type for persistence "equality", ie. Equality of persistent state.

Parameters:
x -
y -
Returns:
boolean
Throws:
HibernateException
See Also:
Type.equals(Object, Object)

nullSafeGet

public Object nullSafeGet(ResultSet rs,
                          String[] names,
                          SessionImplementor session,
                          Object owner)
                   throws HibernateException,
                          SQLException
Description copied from interface: Type
Retrieve an instance of the mapped class from a JDBC resultset. Implementors should handle possibility of null values.

Parameters:
rs -
names - the column names
session -
owner - the parent entity
Returns:
Object
Throws:
HibernateException
SQLException
See Also:
Type.nullSafeGet(ResultSet, String[], SessionImplementor, Object)

nullSafeGet

public Object nullSafeGet(ResultSet rs,
                          String columnName,
                          SessionImplementor session,
                          Object owner)
                   throws HibernateException,
                          SQLException
Description copied from interface: Type
Retrieve an instance of the mapped class from a JDBC resultset. Implementations should handle possibility of null values. This method might be called if the type is known to be a single-column type.

Parameters:
rs -
columnName - the column name
session -
owner - the parent entity
Returns:
Object
Throws:
SQLException
HibernateException
See Also:
Type.nullSafeGet(ResultSet, String, SessionImplementor, Object)

nullSafeSet

public void nullSafeSet(PreparedStatement st,
                        Object value,
                        int index,
                        SessionImplementor session)
                 throws HibernateException,
                        SQLException
Description copied from interface: Type
Write an instance of the mapped class to a prepared statement. Implementors should handle possibility of null values. A multi-column type should be written to parameters starting from index.

Parameters:
st -
value - the object to write
index - statement parameter index
session -
Throws:
SQLException
HibernateException
See Also:
Type.nullSafeSet(PreparedStatement, Object, int, SessionImplementor)

toString

public String toString(Object value,
                       SessionFactoryImplementor factory)
Description copied from interface: Type
A representation of the value to be embedded in an XML element.

Parameters:
value -
factory -
Returns:
String

fromString

public Object fromString(String xml)
Description copied from interface: Type
Parse the XML representation of an instance.

Parameters:
xml -
Returns:
an instance of the type

getName

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

Returns:
String the Hibernate type name
See Also:
Type.getName()

deepCopy

public Object deepCopy(Object value)
                throws HibernateException
Description copied from interface: Type
Return a deep copy of the persistent state, stopping at entities and at collections.

Parameters:
value - generally a collection element or entity field
Returns:
Object a copy
Throws:
HibernateException
See Also:
Type.deepCopy(Object)

isMutable

public boolean isMutable()
Description copied from interface: Type
Are objects of this type mutable. (With respect to the referencing object ... entities and collections are considered immutable because they manage their own internal state.)

Returns:
boolean
See Also:
Type.isMutable()

hasNiceEquals

public boolean hasNiceEquals()
Description copied from interface: Type
Does this type implement a well-behaved equals() method. (ie. one that is consistent with Type.equals().) Strictly, if this method returns true then x.equals(y) implies Type.equals(x, y) and also Type.equals(x, y) implies that probably x.equals(y)

See Also:
Object.equals(java.lang.Object), Type.equals(java.lang.Object, java.lang.Object)

equals

public boolean equals(Object object)
Overrides:
equals in class AbstractType

hashCode

public int hashCode()
Overrides:
hashCode in class AbstractType