org.hibernate.type

Class SpecialOneToOneType

Implemented Interfaces:
AssociationType, Serializable, Type

public class SpecialOneToOneType
extends OneToOneType

A one-to-one association that maps to specific formula(s) instead of the primary key column of the owning entity.
Author:
Gavin King

Field Summary

Fields inherited from class org.hibernate.type.EntityType

isEmbeddedInXML, uniqueKeyPropertyName

Constructor Summary

SpecialOneToOneType(String referencedEntityName, ForeignKeyDirection foreignKeyType, String uniqueKeyPropertyName, boolean lazy, boolean unwrapProxy, String entityName, String propertyName)

Method Summary

Object
assemble(Serializable oid, SessionImplementor session, Object owner)
Reconstruct the object from its cached "disassembled" state.
Serializable
disassemble(Object value, SessionImplementor session, Object owner)
Return a cacheable "disassembled" representation of the object.
int
getColumnSpan(Mapping mapping)
How many columns are used to persist this type.
Object
hydrate(ResultSet rs, String[] names, SessionImplementor session, Object owner)
Retrieve an instance of the mapped class, or the identifier of an entity or collection, from a JDBC resultset.
int[]
sqlTypes(Mapping mapping)
Return the SQL type codes for the columns mapped by this type.
boolean
useLHSPrimaryKey()

Methods inherited from class org.hibernate.type.OneToOneType

assemble, disassemble, getColumnSpan, getForeignKeyDirection, getPropertyName, hydrate, isAlwaysDirtyChecked, isDirty, isDirty, isModified, isNull, isNullable, isOneToOne, nullSafeSet, nullSafeSet, sqlTypes, toColumnNullness, useLHSPrimaryKey

Methods inherited from class org.hibernate.type.EntityType

compare, deepCopy, fromXMLNode, getAssociatedEntityName, getAssociatedEntityName, getAssociatedJoinable, getHashCode, getIdentifier, getIdentifierOrUniqueKeyPropertyName, getIdentifierOrUniqueKeyType, getLHSPropertyName, getName, getOnCondition, getPropertyName, getRHSUniqueKeyPropertyName, getReturnedClass, getSemiResolvedType, isAssociationType, isEmbeddedInXML, isEntityType, isEqual, isMutable, isNotEmbedded, isNull, isNullable, isOneToOne, isReferenceToPrimaryKey, isSame, isXMLElement, loadByUniqueKey, nullSafeGet, nullSafeGet, replace, resolve, resolveIdentifier, setToXMLNode, toLoggableString, toString

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

Constructor Details

SpecialOneToOneType

public SpecialOneToOneType(String referencedEntityName,
                           ForeignKeyDirection foreignKeyType,
                           String uniqueKeyPropertyName,
                           boolean lazy,
                           boolean unwrapProxy,
                           String entityName,
                           String propertyName)

Method Details

assemble

public Object assemble(Serializable oid,
                       SessionImplementor session,
                       Object owner)
            throws HibernateException
Reconstruct the object from its cached "disassembled" state.
Specified by:
assemble in interface Type
Overrides:
assemble in interface OneToOneType
Parameters:
session - the session
owner - the parent entity object
Returns:
the the object

disassemble

public Serializable disassemble(Object value,
                                SessionImplementor session,
                                Object owner)
            throws HibernateException
Return a cacheable "disassembled" representation of the object.
Specified by:
disassemble in interface Type
Overrides:
disassemble in interface OneToOneType
Parameters:
value - the value to cache
session - the session
owner - optional parent entity object (needed for collections)
Returns:
the disassembled, deep cloned state

getColumnSpan

public int getColumnSpan(Mapping mapping)
            throws MappingException
How many columns are used to persist this type.
Specified by:
getColumnSpan in interface Type
Overrides:
getColumnSpan in interface OneToOneType

hydrate

public Object hydrate(ResultSet rs,
                      String[] names,
                      SessionImplementor session,
                      Object owner)
            throws HibernateException,
                   SQLException
Retrieve an instance of the mapped class, or the identifier of an entity or collection, from a JDBC resultset. This is useful for 2-phase property initialization - the second phase is a call to resolveIdentifier().
Specified by:
hydrate in interface Type
Overrides:
hydrate in interface OneToOneType
Parameters:
rs -
names - the column names
session - the session
owner - the parent entity
Returns:
Object an identifier or actual value

sqlTypes

public int[] sqlTypes(Mapping mapping)
            throws MappingException
Return the SQL type codes for the columns mapped by this type. The codes are defined on java.sql.Types.
Specified by:
sqlTypes in interface Type
Overrides:
sqlTypes in interface OneToOneType
Returns:
the typecodes
See Also:
java.sql.Types

useLHSPrimaryKey

public boolean useLHSPrimaryKey()
Specified by:
useLHSPrimaryKey in interface AssociationType
Overrides:
useLHSPrimaryKey in interface OneToOneType