org.hibernate.test.annotations.type
Class MyOidType

java.lang.Object
  extended by org.hibernate.test.annotations.type.MyOidType
All Implemented Interfaces:
CompositeUserType

public class MyOidType
extends Object
implements CompositeUserType


Field Summary
static String[] PROPERTY_NAMES
           
static Type[] TYPES
           
 
Constructor Summary
MyOidType()
           
 
Method Summary
 Object assemble(Serializable cached, SessionImplementor aSessionImplementor, Object aObject)
          Reconstruct an object from the cacheable representation.
 Object deepCopy(Object aObject)
          Return a deep copy of the persistent state, stopping at entities and at collections.
 Serializable disassemble(Object value, SessionImplementor aSessionImplementor)
          Transform the object into its cacheable representation.
 boolean equals(Object x, Object y)
          Compare two instances of the class mapped by this type for persistence "equality".
 String[] getPropertyNames()
          Get the "property names" that may be used in a query.
 Type[] getPropertyTypes()
          Get the corresponding "property types".
 Object getPropertyValue(Object aObject, int i)
          Get the value of a property.
 int hashCode(Object aObject)
          Get a hashcode for the instance, consistent with persistence "equality"
 boolean isMutable()
          Check if objects of this type mutable.
 Object nullSafeGet(ResultSet aResultSet, String[] names, SessionImplementor aSessionImplementor, Object aObject)
          Retrieve an instance of the mapped class from a JDBC resultset.
 void nullSafeSet(PreparedStatement aPreparedStatement, Object value, int index, SessionImplementor aSessionImplementor)
          Write an instance of the mapped class to a prepared statement.
 Object replace(Object original, Object target, SessionImplementor aSessionImplementor, Object aObject2)
          During merge, replace the existing (target) value in the entity we are merging to with a new (original) value from the detached entity we are merging.
 Class returnedClass()
          The class returned by nullSafeGet().
 void setPropertyValue(Object aObject, int i, Object aObject1)
          Set the value of a property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_NAMES

public static final String[] PROPERTY_NAMES

TYPES

public static final Type[] TYPES
Constructor Detail

MyOidType

public MyOidType()
Method Detail

getPropertyNames

public String[] getPropertyNames()
Description copied from interface: CompositeUserType
Get the "property names" that may be used in a query.

Specified by:
getPropertyNames in interface CompositeUserType
Returns:
an array of "property names"

getPropertyTypes

public Type[] getPropertyTypes()
Description copied from interface: CompositeUserType
Get the corresponding "property types".

Specified by:
getPropertyTypes in interface CompositeUserType
Returns:
an array of Hibernate types

getPropertyValue

public Object getPropertyValue(Object aObject,
                               int i)
                        throws HibernateException
Description copied from interface: CompositeUserType
Get the value of a property.

Specified by:
getPropertyValue in interface CompositeUserType
Parameters:
aObject - an instance of class mapped by this "type"
Returns:
the property value
Throws:
HibernateException

setPropertyValue

public void setPropertyValue(Object aObject,
                             int i,
                             Object aObject1)
                      throws HibernateException
Description copied from interface: CompositeUserType
Set the value of a property.

Specified by:
setPropertyValue in interface CompositeUserType
Parameters:
aObject - an instance of class mapped by this "type"
aObject1 - the value to set
Throws:
HibernateException

returnedClass

public Class returnedClass()
Description copied from interface: CompositeUserType
The class returned by nullSafeGet().

Specified by:
returnedClass in interface CompositeUserType
Returns:
Class

equals

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

Specified by:
equals in interface CompositeUserType
Throws:
HibernateException

hashCode

public int hashCode(Object aObject)
             throws HibernateException
Description copied from interface: CompositeUserType
Get a hashcode for the instance, consistent with persistence "equality"

Specified by:
hashCode in interface CompositeUserType
Throws:
HibernateException

nullSafeGet

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

Specified by:
nullSafeGet in interface CompositeUserType
Parameters:
aResultSet - a JDBC result set
names - the column names
aObject - the containing entity
Returns:
Object
Throws:
HibernateException
SQLException

nullSafeSet

public void nullSafeSet(PreparedStatement aPreparedStatement,
                        Object value,
                        int index,
                        SessionImplementor aSessionImplementor)
                 throws HibernateException,
                        SQLException
Description copied from interface: CompositeUserType
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.

Specified by:
nullSafeSet in interface CompositeUserType
Parameters:
aPreparedStatement - a JDBC prepared statement
value - the object to write
index - statement parameter index
Throws:
HibernateException
SQLException

deepCopy

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

Specified by:
deepCopy in interface CompositeUserType
Parameters:
aObject - generally a collection element or entity field
Returns:
Object a copy
Throws:
HibernateException

isMutable

public boolean isMutable()
Description copied from interface: CompositeUserType
Check if objects of this type mutable.

Specified by:
isMutable in interface CompositeUserType
Returns:
boolean

disassemble

public Serializable disassemble(Object value,
                                SessionImplementor aSessionImplementor)
                         throws HibernateException
Description copied from interface: CompositeUserType
Transform the object into its cacheable representation. At the very least this method should perform a deep copy. That may not be enough for some implementations, however; for example, associations must be cached as identifier values. (optional operation)

Specified by:
disassemble in interface CompositeUserType
Parameters:
value - the object to be cached
Returns:
a cachable representation of the object
Throws:
HibernateException

assemble

public Object assemble(Serializable cached,
                       SessionImplementor aSessionImplementor,
                       Object aObject)
                throws HibernateException
Description copied from interface: CompositeUserType
Reconstruct an object from the cacheable representation. At the very least this method should perform a deep copy. (optional operation)

Specified by:
assemble in interface CompositeUserType
Parameters:
cached - the object to be cached
aObject - the owner of the cached object
Returns:
a reconstructed object from the cachable representation
Throws:
HibernateException

replace

public Object replace(Object original,
                      Object target,
                      SessionImplementor aSessionImplementor,
                      Object aObject2)
               throws HibernateException
Description copied from interface: CompositeUserType
During merge, replace the existing (target) value in the entity we are merging to with a new (original) value from the detached entity we are merging. For immutable objects, or null values, it is safe to simply return the first parameter. For mutable objects, it is safe to return a copy of the first parameter. However, since composite user types often define component values, it might make sense to recursively replace component values in the target object.

Specified by:
replace in interface CompositeUserType
Throws:
HibernateException


Copyright © 2001-2012 Red Hat, Inc. All Rights Reserved.