Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.hibernate.type
Class OneToOneType

    java.lang.Object
      org.hibernate.type.AbstractType
          org.hibernate.type.EntityType
              org.hibernate.type.OneToOneType

All Implemented Interfaces:
  Serializable, AssociationType, Type

Direct Known Subclasses:
  SpecialOneToOneType

    public class OneToOneType

extends EntityType

A one-to-one association to an entity

See Also:
  Serialized Form

Field Summary

Fields inherited from class org.hibernate.type.EntityType
`isEmbeddedInXML, uniqueKeyPropertyName`

Fields inherited from class org.hibernate.type.AbstractType
`LEGACY_DEFAULT_SIZE, LEGACY_DICTATED_SIZE`

Constructor Summary
`OneToOneType(TypeFactory.TypeScope scope, String referencedEntityName, ForeignKeyDirection foreignKeyType, String uniqueKeyPropertyName, boolean lazy, boolean unwrapProxy, boolean isEmbeddedInXML, String entityName, String propertyName)`

Method Summary
`Object` | `assemble(Serializable oid, SessionImplementor session, Object owner)` Reconstruct the object from its disassembled state.
`Size[]` | `defaultSizes(Mapping mapping)` Defines the column sizes to use according to this type if the user did not explicitly say (and if no `Type.dictatedSizes(org.hibernate.engine.spi.Mapping)` were given).
`Size[]` | `dictatedSizes(Mapping mapping)` Return the column sizes dictated by this type.
`Serializable` | `disassemble(Object value, SessionImplementor session, Object owner)` Return a disassembled representation of the object.
`int` | `getColumnSpan(Mapping session)` How many columns are used to persist this type.
`ForeignKeyDirection` | `getForeignKeyDirection()` Get the foreign key directionality of this association
`String` | `getPropertyName()`
`Object` | `hydrate(ResultSet rs, String[] names, SessionImplementor session, Object owner)` Extract a value from the JDBC result set.
`boolean` | `isAlwaysDirtyChecked()` We don't need to dirty check one-to-one because of how assemble/disassemble is implemented and because a one-to-one association is never dirty
`boolean` | `isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session)` Should the parent be considered dirty, given both the old and current value?
`boolean` | `isDirty(Object old, Object current, SessionImplementor session)` Should the parent be considered dirty, given both the old and current value?
`boolean` | `isModified(Object old, Object current, boolean[] checkable, SessionImplementor session)` Has the value been modified compared to the current database state? The difference between this and the `Type.isDirty(java.lang.Object, java.lang.Object, org.hibernate.engine.spi.SessionImplementor)` methods is that here we need to account for "partially" built values.
`boolean` | `isNull(Object owner, SessionImplementor session)`
`protected boolean` | `isNullable()`
`boolean` | `isOneToOne()` Is the association modeled here defined as a 1-1 in the database (physical model)?
`void` | `nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SessionImplementor session)` Bind a value represented by an instance of the `mapped class` to the JDBC prepared statement, ignoring some columns as dictated by the 'settable' parameter.
`void` | `nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)` Bind a value represented by an instance of the `mapped class` to the JDBC prepared statement.
`int[]` | `sqlTypes(Mapping session)` Return the JDBC types codes (per `Types`) for the columns mapped by this type.
`boolean[]` | `toColumnNullness(Object value, Mapping mapping)` Given an instance of the type, return an array of boolean, indicating which mapped columns would be null.
`boolean` | `useLHSPrimaryKey()` Is the primary key of the owning entity table to be used in the join?

Methods inherited from class org.hibernate.type.EntityType
`compare, deepCopy, fromXMLNode, getAssociatedEntityName, getAssociatedEntityName, getAssociatedJoinable, getHashCode, getIdentifier, getIdentifierOrUniqueKeyPropertyName, getIdentifierOrUniqueKeyType, getLHSPropertyName, getName, getOnCondition, getReturnedClass, getRHSUniqueKeyPropertyName, getSemiResolvedType, isAssociationType, isEmbeddedInXML, isEntityType, isEqual, isLogicalOneToOne, isMutable, isNotEmbedded, isReferenceToPrimaryKey, isSame, isXMLElement, loadByUniqueKey, nullSafeGet, nullSafeGet, replace, resolve, resolveIdentifier, scope, setToXMLNode, toLoggableString, toString`

Methods inherited from class org.hibernate.type.AbstractType
`beforeAssemble, getHashCode, isAnyType, isCollectionType, isComponentType, isEqual, replace, replaceNode, semiResolve`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.hibernate.type.Type
`beforeAssemble, getHashCode, isAnyType, isCollectionType, isComponentType, isEqual, replace, semiResolve`

Constructor Detail

### OneToOneType

    public OneToOneType(TypeFactory.TypeScope scope,
                        String referencedEntityName,
                        ForeignKeyDirection foreignKeyType,
                        String uniqueKeyPropertyName,
                        boolean lazy,
                        boolean unwrapProxy,
                        boolean isEmbeddedInXML,
                        String entityName,
                        String propertyName)

Method Detail

### getPropertyName

    public String getPropertyName()

  Overrides:
    `getPropertyName` in class `EntityType`

### isNull

    public boolean isNull(Object owner,
                          SessionImplementor session)

  Overrides:
    `isNull` in class `EntityType`

### getColumnSpan

    public int getColumnSpan(Mapping session)
                      throws MappingException

  Description copied from interface: `Type`
  How many columns are used to persist this type. Always the same as `sqlTypes(mapping).length`

  Parameters:
    `session` - The mapping object :/
  Returns:
    The number of columns
  Throws:
    `MappingException` - Generally indicates an issue accessing the passed mapping object.

### sqlTypes

    public int[] sqlTypes(Mapping session)
                   throws MappingException

  Description copied from interface: `Type`
  Return the JDBC types codes (per `Types`) for the columns mapped by this type.

  NOTE: The number of elements in this array matches the return from `Type.getColumnSpan(org.hibernate.engine.spi.Mapping)`.

  Parameters:
    `session` - The mapping object :/
  Returns:
    The JDBC type codes.
  Throws:
    `MappingException` - Generally indicates an issue accessing the passed mapping object.

### dictatedSizes

    public Size[] dictatedSizes(Mapping mapping)
                         throws MappingException

  Description copied from interface: `Type`
  Return the column sizes dictated by this type. For example, the mapping for a `char`/`Character` would have a dictated length limit of 1; for a string-based `UUID` would have a size limit of 36; etc.

  NOTE: The number of elements in this array matches the return from `Type.getColumnSpan(org.hibernate.engine.spi.Mapping)`.

  Parameters:
    `mapping` - The mapping object :/
  Returns:
    The dictated sizes.
  Throws:
    `MappingException` - Generally indicates an issue accessing the passed mapping object.

### defaultSizes

    public Size[] defaultSizes(Mapping mapping)
                        throws MappingException

  Description copied from interface: `Type`
  Defines the column sizes to use according to this type if the user did not explicitly say (and if no `Type.dictatedSizes(org.hibernate.engine.spi.Mapping)` were given).

  NOTE: The number of elements in this array matches the return from `Type.getColumnSpan(org.hibernate.engine.spi.Mapping)`.

  Parameters:
    `mapping` - The mapping object :/
  Returns:
    The default sizes.
  Throws:
    `MappingException` - Generally indicates an issue accessing the passed mapping object.

### toColumnNullness

    public boolean[] toColumnNullness(Object value,
                                      Mapping mapping)

  Description copied from interface: `Type`
  Given an instance of the type, return an array of boolean, indicating which mapped columns would be null.

  Parameters:
    `value` - an instance of the type
    `mapping` - The mapping abstraction
  Returns:
    array indicating column nullness for a value instance

### nullSafeSet

    public void nullSafeSet(PreparedStatement st,
                            Object value,
                            int index,
                            boolean[] settable,
                            SessionImplementor session)

  Description copied from interface: `Type`
  Bind a value represented by an instance of the `mapped class` to the JDBC prepared statement, ignoring some columns as dictated by the 'settable' parameter. Implementors should handle the possibility of null values. A multi-column type should bind parameters starting from `index`.

  Parameters:
    `st` - The JDBC prepared statement to which to bind
    `value` - the object to write
    `index` - starting parameter bind index
    `settable` - an array indicating which columns to bind/ignore
    `session` - The originating session

### nullSafeSet

    public void nullSafeSet(PreparedStatement st,
                            Object value,
                            int index,
                            SessionImplementor session)

  Description copied from interface: `Type`
  Bind a value represented by an instance of the `mapped class` to the JDBC prepared statement. Implementors should handle possibility of null values. A multi-column type should bind parameters starting from `index`.

  Parameters:
    `st` - The JDBC prepared statement to which to bind
    `value` - the object to write
    `index` - starting parameter bind index
    `session` - The originating session

### isOneToOne

    public boolean isOneToOne()

  Description copied from class: `EntityType`
  Is the association modeled here defined as a 1-1 in the database (physical model)?

  Specified by:
    `isOneToOne` in class `EntityType`
  Returns:
    True if a 1-1 in the database; false otherwise.

### isDirty

    public boolean isDirty(Object old,
                           Object current,
                           SessionImplementor session)

  Description copied from interface: `Type`
  Should the parent be considered dirty, given both the old and current value?

  Specified by:
    `isDirty` in interface `Type`
  Overrides:
    `isDirty` in class `AbstractType`
  Parameters:
    `old` - the old value
    `current` - the current value
    `session` - The session from which the request originated.
  Returns:
    true if the field is dirty

### isDirty

    public boolean isDirty(Object old,
                           Object current,
                           boolean[] checkable,
                           SessionImplementor session)

  Description copied from interface: `Type`
  Should the parent be considered dirty, given both the old and current value?

  Parameters:
    `old` - the old value
    `current` - the current value
    `checkable` - An array of booleans indicating which columns making up the value are actually checkable
    `session` - The session from which the request originated.
  Returns:
    true if the field is dirty

### isModified

    public boolean isModified(Object old,
                              Object current,
                              boolean[] checkable,
                              SessionImplementor session)

  Description copied from interface: `Type`
  Has the value been modified compared to the current database state? The difference between this and the `Type.isDirty(java.lang.Object, java.lang.Object, org.hibernate.engine.spi.SessionImplementor)` methods is that here we need to account for "partially" built values. This is really only an issue with association types. For most type implementations it is enough to simply delegate to `Type.isDirty(java.lang.Object, java.lang.Object, org.hibernate.engine.spi.SessionImplementor)` here/

  Specified by:
    `isModified` in interface `Type`
  Overrides:
    `isModified` in class `AbstractType`
  Parameters:
    `old` - the database state, in a "hydrated" form, with identifiers unresolved
    `current` - the current state of the object
    `checkable` - which columns are actually updatable
    `session` - The session from which the request originated.
  Returns:
    true if the field has been modified

### getForeignKeyDirection

    public ForeignKeyDirection getForeignKeyDirection()

  Description copied from interface: `AssociationType`
  Get the foreign key directionality of this association

### hydrate

    public Object hydrate(ResultSet rs,
                          String[] names,
                          SessionImplementor session,
                          Object owner)
                   throws HibernateException,
                          SQLException

  Description copied from interface: `Type`
  Extract a value from the JDBC result set. This is useful for 2-phase property initialization - the second phase is a call to `Type.resolve(java.lang.Object, org.hibernate.engine.spi.SessionImplementor, java.lang.Object)` This hydrated value will be either:
  - in the case of an entity or collection type, the key
  - otherwise, the value itself

  Specified by:
    `hydrate` in interface `Type`
  Overrides:
    `hydrate` in class `AbstractType`
  Parameters:
    `rs` - The JDBC result set
    `names` - the column names making up this type value (use to read from result set)
    `session` - The originating session
    `owner` - the parent entity
  Returns:
    An entity or collection key, or an actual value.
  Throws:
    `HibernateException` - An error from Hibernate
    `SQLException` - An error from the JDBC driver
  See Also:
    `Type.resolve(java.lang.Object, org.hibernate.engine.spi.SessionImplementor, java.lang.Object)`

### isNullable

    protected boolean isNullable()

  Specified by:
    `isNullable` in class `EntityType`

### useLHSPrimaryKey

    public boolean useLHSPrimaryKey()

  Description copied from interface: `AssociationType`
  Is the primary key of the owning entity table to be used in the join?

### disassemble

    public Serializable disassemble(Object value,
                                    SessionImplementor session,
                                    Object owner)
                             throws HibernateException

  Description copied from interface: `Type`
  Return a disassembled representation of the object. This is the value Hibernate will use in second level caching, so care should be taken to break values down to their simplest forms; for entities especially, this means breaking them down into their constituent parts.

  Specified by:
    `disassemble` in interface `Type`
  Overrides:
    `disassemble` in class `AbstractType`
  Parameters:
    `value` - the value to cache
    `session` - the originating session
    `owner` - optional parent entity object (needed for collections)
  Returns:
    the disassembled, deep cloned state
  Throws:
    `HibernateException` - An error from Hibernate

### assemble

    public Object assemble(Serializable oid,
                           SessionImplementor session,
                           Object owner)
                    throws HibernateException

  Description copied from interface: `Type`
  Reconstruct the object from its disassembled state. This method is the reciprocal of `Type.disassemble(java.lang.Object, org.hibernate.engine.spi.SessionImplementor, java.lang.Object)`

  Specified by:
    `assemble` in interface `Type`
  Overrides:
    `assemble` in class `AbstractType`
  Parameters:
    `oid` - the disassembled state from the cache
    `session` - the originating session
    `owner` - the parent entity object
  Returns:
    the (re)assembled object
  Throws:
    `HibernateException` - An error from Hibernate

### isAlwaysDirtyChecked

    public boolean isAlwaysDirtyChecked()

  We don't need to dirty check one-to-one because of how assemble/disassemble is implemented and because a one-to-one association is never dirty

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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