Package 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
A one-to-one association to an entity
- See Also:
-
Field Summary
Fields inherited from class org.hibernate.type.EntityType
uniqueKeyPropertyName
-
Constructor Summary
ConstructorsConstructorDescriptionOneToOneType
(OneToOneType original, String superTypeEntityName) OneToOneType
(TypeConfiguration typeConfiguration, String referencedEntityName, ForeignKeyDirection foreignKeyType, boolean referenceToPrimaryKey, String uniqueKeyPropertyName, boolean lazy, boolean unwrapProxy, String entityName, String propertyName, boolean constrained) -
Method Summary
Modifier and TypeMethodDescriptionassemble
(Serializable oid, SharedSessionContractImplementor session, Object owner) Reconstruct the object from its disassembled state.disassemble
(Object value, SessionFactoryImplementor sessionFactory) Return a disassembled representation of the object.disassemble
(Object value, SharedSessionContractImplementor session, Object owner) Return a disassembled representation of the object.int
getColumnSpan
(MappingContext session) How many columns are used to persist this type?Get the foreign key directionality of this associationint[]
getSqlTypeCodes
(MappingContext mappingContext) boolean
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 dirtyboolean
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 theType.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) boolean
The nullability of the property.boolean
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 themapped class
to the given JDBCPreparedStatement
, ignoring some columns as dictated by thesettable
parameter.boolean[]
toColumnNullness
(Object value, MappingContext mapping) Given an instance of the type, return an array ofboolean
values indicating which mapped columns would be null.boolean
Is the primary key of the owning entity table to be used in the join?Methods inherited from class org.hibernate.type.EntityType
compare, compare, deepCopy, getAssociatedEntityName, getAssociatedEntityName, getAssociatedEntityPersister, getAssociatedJoinable, getHashCode, getIdentifier, getIdentifier, getIdentifierOrUniqueKeyPropertyName, getIdentifierOrUniqueKeyPropertyName, getIdentifierOrUniqueKeyType, getIdentifierOrUniqueKeyType, getLHSPropertyName, getName, getReturnedClass, getRHSUniqueKeyPropertyName, isAssociationType, isEager, isEntityType, isEqual, isLogicalOneToOne, isMutable, isReferenceToIdentifierProperty, isReferenceToPrimaryKey, isSame, loadByUniqueKey, nullSafeSet, replace, requireIdentifierOrUniqueKeyType, resolve, resolveIdentifier, resolveIdentifier, scope, toLoggableString, toString
Methods inherited from class org.hibernate.type.AbstractType
beforeAssemble, getHashCode, isAnyType, isCollectionType, isComponentType, isEqual, replace
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, getColumnSpan, getHashCode, getReturnedClassName, getSqlTypeCodes, getTypeForEqualsHashCode, isAnyType, isCollectionType, isComponentType, isEqual, replace, toColumnNullness
-
Constructor Details
-
OneToOneType
public OneToOneType(TypeConfiguration typeConfiguration, String referencedEntityName, ForeignKeyDirection foreignKeyType, boolean referenceToPrimaryKey, String uniqueKeyPropertyName, boolean lazy, boolean unwrapProxy, String entityName, String propertyName, boolean constrained) -
OneToOneType
-
-
Method Details
-
getPropertyName
- Overrides:
getPropertyName
in classEntityType
-
getColumnSpan
Description copied from interface:Type
How many columns are used to persist this type?Always the same as
getSqlTypCodes(mappingContext).length
.- Parameters:
session
- The mapping Context objectMappingContext
- Returns:
- The number of columns
- Throws:
MappingException
- Generally indicates an issue accessing the passed mappingContext object.
-
getSqlTypeCodes
Description copied from interface:Type
Return the JDBC types codes as defined byTypes
orSqlTypes
for the columns mapped by this type.The number of elements in this array must match the return from
Type.getColumnSpan(org.hibernate.engine.spi.Mapping)
.- Parameters:
mappingContext
- The mapping contextMappingContext
:/- Returns:
- The JDBC type codes.
-
toColumnNullness
Description copied from interface:Type
Given an instance of the type, return an array ofboolean
values indicating which mapped columns would be null.- Parameters:
value
- an instance of the typemapping
- The mapping contextMappingContext
- Returns:
- array indicating column nullness for a value instance
-
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 classEntityType
- Returns:
- True if a 1-1 in the database; false otherwise.
-
getForeignKeyDirection
Description copied from interface:AssociationType
Get the foreign key directionality of this association -
isNullable
public boolean isNullable()Description copied from class:EntityType
The nullability of the property.- Specified by:
isNullable
in classEntityType
- Returns:
- The nullability of the property.
-
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
Description copied from interface:Type
Return a disassembled representation of the object. This is the representation that is stored in the second-level cache.A reference to an associated entity should be disassembled to its primary key value.
A high-quality implementation of this method should ensure that:
Objects.equals(disassemble(x,s), disassemble(y,s))
== isEqual(x,y,sf)and that:
Objects.equals(x, assemble(disassemble(x,s),s,o))
That is, the implementation must be consistent with
Type.isEqual(Object, Object, SessionFactoryImplementor)
and withType.assemble(Serializable, SharedSessionContractImplementor, Object)
.- Specified by:
disassemble
in interfaceType
- Overrides:
disassemble
in classAbstractType
- Parameters:
value
- the value to cachesessionFactory
- the session factory- Returns:
- the disassembled, deep cloned state
-
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
-