public class OneToOneType extends EntityType
A one-to-one association to an entity
uniqueKeyPropertyName
LEGACY_DEFAULT_SIZE, LEGACY_DICTATED_SIZE
Constructor and Description |
---|
OneToOneType(OneToOneType original,
String superTypeEntityName) |
OneToOneType(TypeFactory.TypeScope scope,
String referencedEntityName,
ForeignKeyDirection foreignKeyType,
boolean referenceToPrimaryKey,
String uniqueKeyPropertyName,
boolean lazy,
boolean unwrapProxy,
String entityName,
String propertyName) |
OneToOneType(TypeFactory.TypeScope scope,
String referencedEntityName,
ForeignKeyDirection foreignKeyType,
String uniqueKeyPropertyName,
boolean lazy,
boolean unwrapProxy,
String entityName,
String propertyName)
|
Modifier and Type | Method and Description |
---|---|
Object |
assemble(Serializable oid,
SharedSessionContractImplementor 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,
SharedSessionContractImplementor 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,
SharedSessionContractImplementor 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,
SharedSessionContractImplementor session)
Should the parent be considered dirty, given both the old and current value?
|
boolean |
isDirty(Object old,
Object current,
SharedSessionContractImplementor session)
Should the parent be considered dirty, given both the old and current value?
|
boolean |
isModified(Object old,
Object current,
boolean[] checkable,
SharedSessionContractImplementor 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.SharedSessionContractImplementor) methods is that here we need to account for "partially" built values. |
boolean |
isNull(Object owner,
SharedSessionContractImplementor 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,
SharedSessionContractImplementor 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. |
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?
|
compare, deepCopy, getAssociatedEntityName, getAssociatedEntityName, getAssociatedEntityPersister, getAssociatedJoinable, getHashCode, getIdentifier, getIdentifierOrUniqueKeyPropertyName, getIdentifierOrUniqueKeyType, getLHSPropertyName, getName, getOnCondition, getOnCondition, getReturnedClass, getRHSUniqueKeyPropertyName, getSemiResolvedType, isAssociationType, isEntityType, isEqual, isLogicalOneToOne, isMutable, isReferenceToPrimaryKey, isSame, loadByUniqueKey, nullSafeGet, nullSafeGet, nullSafeSet, replace, requireIdentifierOrUniqueKeyType, resolve, resolve, resolveIdentifier, resolveIdentifier, scope, toLoggableString, toString
beforeAssemble, getHashCode, isAnyType, isCollectionType, isComponentType, isEqual, replace, semiResolve
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
beforeAssemble, getHashCode, isAnyType, isCollectionType, isComponentType, isEqual, replace, semiResolve
@Deprecated public OneToOneType(TypeFactory.TypeScope scope, String referencedEntityName, ForeignKeyDirection foreignKeyType, String uniqueKeyPropertyName, boolean lazy, boolean unwrapProxy, String entityName, String propertyName)
public OneToOneType(TypeFactory.TypeScope scope, String referencedEntityName, ForeignKeyDirection foreignKeyType, boolean referenceToPrimaryKey, String uniqueKeyPropertyName, boolean lazy, boolean unwrapProxy, String entityName, String propertyName)
public OneToOneType(OneToOneType original, String superTypeEntityName)
public String getPropertyName()
getPropertyName
in class EntityType
public boolean isNull(Object owner, SharedSessionContractImplementor session)
isNull
in class EntityType
public int getColumnSpan(Mapping session) throws MappingException
Type
How many columns are used to persist this type. Always the same as sqlTypes(mapping).length
session
- The mapping object :/MappingException
- Generally indicates an issue accessing the passed mapping object.public int[] sqlTypes(Mapping session) throws MappingException
Type
Return the JDBC types codes (per Types
) for the columns mapped by this type.
<p/>
NOTE: The number of elements in this array matches the return from Type.getColumnSpan(org.hibernate.engine.spi.Mapping)
.
session
- The mapping object :/MappingException
- Generally indicates an issue accessing the passed mapping object.public Size[] dictatedSizes(Mapping mapping) throws MappingException
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.
<p/>
NOTE: The number of elements in this array matches the return from Type.getColumnSpan(org.hibernate.engine.spi.Mapping)
.
mapping
- The mapping object :/MappingException
- Generally indicates an issue accessing the passed mapping object.public Size[] defaultSizes(Mapping mapping) throws MappingException
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).
<p/>
NOTE: The number of elements in this array matches the return from Type.getColumnSpan(org.hibernate.engine.spi.Mapping)
.
mapping
- The mapping object :/MappingException
- Generally indicates an issue accessing the passed mapping object.public boolean[] toColumnNullness(Object value, Mapping mapping)
Type
Given an instance of the type, return an array of boolean, indicating which mapped columns would be null.
value
- an instance of the typemapping
- The mapping abstractionpublic void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SharedSessionContractImplementor session)
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 <tt>index</tt>.
nullSafeSet
in interface Type
nullSafeSet
in class EntityType
st
- The JDBC prepared statement to which to bindvalue
- the object to writeindex
- starting parameter bind indexsettable
- an array indicating which columns to bind/ignoresession
- The originating sessionpublic boolean isOneToOne()
EntityType
Is the association modeled here defined as a 1-1 in the database (physical model)?
isOneToOne
in class EntityType
public boolean isDirty(Object old, Object current, SharedSessionContractImplementor session)
Type
Should the parent be considered dirty, given both the old and current value?
isDirty
in interface Type
isDirty
in class AbstractType
old
- the old valuecurrent
- the current valuesession
- The session from which the request originated.public boolean isDirty(Object old, Object current, boolean[] checkable, SharedSessionContractImplementor session)
Type
Should the parent be considered dirty, given both the old and current value?
old
- the old valuecurrent
- the current valuecheckable
- An array of booleans indicating which columns making up the value are actually checkablesession
- The session from which the request originated.public boolean isModified(Object old, Object current, boolean[] checkable, SharedSessionContractImplementor session)
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.SharedSessionContractImplementor)
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.SharedSessionContractImplementor)
here/
isModified
in interface Type
isModified
in class AbstractType
old
- the database state, in a "hydrated" form, with identifiers unresolvedcurrent
- the current state of the objectcheckable
- which columns are actually updatablesession
- The session from which the request originated.public ForeignKeyDirection getForeignKeyDirection()
AssociationType
Get the foreign key directionality of this association
public Object hydrate(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException
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.SharedSessionContractImplementor, java.lang.Object)
This hydrated value will be either:<ul>
<li>in the case of an entity or collection type, the key</li>
<li>otherwise, the value itself</li>
</ul>
hydrate
in interface Type
hydrate
in class AbstractType
rs
- The JDBC result setnames
- the column names making up this type value (use to read from result set)session
- The originating sessionowner
- the parent entityHibernateException
- An error from HibernateSQLException
- An error from the JDBC driverType.resolve(java.lang.Object, org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object)
protected boolean isNullable()
isNullable
in class EntityType
public boolean useLHSPrimaryKey()
AssociationType
Is the primary key of the owning entity table to be used in the join?
public Serializable disassemble(Object value, SharedSessionContractImplementor session, Object owner) throws HibernateException
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.
disassemble
in interface Type
disassemble
in class AbstractType
value
- the value to cachesession
- the originating sessionowner
- optional parent entity object (needed for collections)HibernateException
- An error from Hibernatepublic Object assemble(Serializable oid, SharedSessionContractImplementor session, Object owner) throws HibernateException
Type
Reconstruct the object from its disassembled state. This method is the reciprocal of Type.disassemble(java.lang.Object, org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object)
assemble
in interface Type
assemble
in class AbstractType
oid
- the disassembled state from the cachesession
- the originating sessionowner
- the parent entity objectHibernateException
- An error from Hibernatepublic 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
Copyright © 2001-2018 Red Hat, Inc. All Rights Reserved.