Package org.hibernate.type
Class ManyToOneType
- java.lang.Object
-
- org.hibernate.type.AbstractType
-
- org.hibernate.type.EntityType
-
- org.hibernate.type.ManyToOneType
-
- All Implemented Interfaces:
java.io.Serializable
,AssociationType
,Type
public class ManyToOneType extends EntityType
A many-to-one association to an entity.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.hibernate.type.EntityType
uniqueKeyPropertyName
-
Fields inherited from class org.hibernate.type.AbstractType
LEGACY_DEFAULT_SIZE, LEGACY_DICTATED_SIZE
-
-
Constructor Summary
Constructors Constructor Description ManyToOneType(ManyToOneType original, java.lang.String superTypeEntityName)
ManyToOneType(TypeFactory.TypeScope scope, java.lang.String referencedEntityName)
Creates a many-to-one association type with the given referenced entity.ManyToOneType(TypeFactory.TypeScope scope, java.lang.String referencedEntityName, boolean lazy)
Creates a many-to-one association type with the given referenced entity and the given laziness characteristicManyToOneType(TypeFactory.TypeScope scope, java.lang.String referencedEntityName, boolean referenceToPrimaryKey, java.lang.String uniqueKeyPropertyName, boolean lazy, boolean unwrapProxy, boolean ignoreNotFound, boolean isLogicalOneToOne)
ManyToOneType(TypeFactory.TypeScope scope, java.lang.String referencedEntityName, boolean referenceToPrimaryKey, java.lang.String uniqueKeyPropertyName, java.lang.String propertyName, boolean lazy, boolean unwrapProxy, boolean ignoreNotFound, boolean isLogicalOneToOne)
ManyToOneType(TypeFactory.TypeScope scope, java.lang.String referencedEntityName, java.lang.String uniqueKeyPropertyName, boolean lazy, boolean unwrapProxy, boolean isEmbeddedInXML, boolean ignoreNotFound, boolean isLogicalOneToOne)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
assemble(java.io.Serializable oid, SharedSessionContractImplementor session, java.lang.Object owner)
Reconstruct the object from its disassembled state.void
beforeAssemble(java.io.Serializable oid, SharedSessionContractImplementor session)
Called before assembling a query result set from the query cache, to allow batch fetching of entities missing from the second-level cache.Size[]
defaultSizes(Mapping mapping)
Defines the column sizes to use according to this type if the user did not explicitly say (and if noType.dictatedSizes(org.hibernate.engine.spi.Mapping)
were given).Size[]
dictatedSizes(Mapping mapping)
Return the column sizes dictated by this type.java.io.Serializable
disassemble(java.lang.Object value, SharedSessionContractImplementor session, java.lang.Object owner)
Return a disassembled representation of the object.int
getColumnSpan(Mapping mapping)
How many columns are used to persist this type.ForeignKeyDirection
getForeignKeyDirection()
Get the foreign key directionality of this associationjava.lang.String
getPropertyName()
java.lang.Object
hydrate(java.sql.ResultSet rs, java.lang.String[] names, SharedSessionContractImplementor session, java.lang.Object owner)
Extract a value from the JDBC result set.boolean
isAlwaysDirtyChecked()
Do we dirty check this association, even when there are no columns to be updated?boolean
isDirty(java.lang.Object old, java.lang.Object current, boolean[] checkable, SharedSessionContractImplementor session)
Should the parent be considered dirty, given both the old and current value?boolean
isDirty(java.lang.Object old, java.lang.Object current, SharedSessionContractImplementor session)
Should the parent be considered dirty, given both the old and current value?boolean
isLogicalOneToOne()
Is the association modeled here a 1-1 according to the logical moidel?boolean
isModified(java.lang.Object old, java.lang.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
isNullable()
boolean
isOneToOne()
Is the association modeled here defined as a 1-1 in the database (physical model)?java.lang.Object
resolve(java.lang.Object value, SharedSessionContractImplementor session, java.lang.Object owner, java.lang.Boolean overridingEager)
The second phase of 2-phase loading.int[]
sqlTypes(Mapping mapping)
Return the JDBC types codes (perTypes
) for the columns mapped by this type.boolean[]
toColumnNullness(java.lang.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, getAssociatedEntityName, getAssociatedEntityName, getAssociatedEntityPersister, getAssociatedJoinable, getHashCode, getIdentifier, getIdentifierOrUniqueKeyPropertyName, getIdentifierOrUniqueKeyType, getLHSPropertyName, getName, getOnCondition, getOnCondition, getReturnedClass, getRHSUniqueKeyPropertyName, getSemiResolvedType, isAssociationType, isEntityType, isEqual, isMutable, isNull, isReferenceToPrimaryKey, isSame, loadByUniqueKey, nullSafeGet, nullSafeGet, nullSafeSet, nullSafeSet, replace, requireIdentifierOrUniqueKeyType, resolve, resolveIdentifier, resolveIdentifier, scope, toLoggableString, toString
-
Methods inherited from class org.hibernate.type.AbstractType
getHashCode, isAnyType, isCollectionType, isComponentType, isEqual, replace, 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
getHashCode, isAnyType, isCollectionType, isComponentType, isEqual, replace, semiResolve
-
-
-
-
Constructor Detail
-
ManyToOneType
public ManyToOneType(TypeFactory.TypeScope scope, java.lang.String referencedEntityName)
Creates a many-to-one association type with the given referenced entity.- Parameters:
scope
- The scope for this instance.referencedEntityName
- The name iof the referenced entity
-
ManyToOneType
public ManyToOneType(TypeFactory.TypeScope scope, java.lang.String referencedEntityName, boolean lazy)
Creates a many-to-one association type with the given referenced entity and the given laziness characteristic- Parameters:
scope
- The scope for this instance.referencedEntityName
- The name iof the referenced entitylazy
- Should the association be handled lazily
-
ManyToOneType
@Deprecated public ManyToOneType(TypeFactory.TypeScope scope, java.lang.String referencedEntityName, java.lang.String uniqueKeyPropertyName, boolean lazy, boolean unwrapProxy, boolean isEmbeddedInXML, boolean ignoreNotFound, boolean isLogicalOneToOne)
-
ManyToOneType
@Deprecated public ManyToOneType(TypeFactory.TypeScope scope, java.lang.String referencedEntityName, boolean referenceToPrimaryKey, java.lang.String uniqueKeyPropertyName, boolean lazy, boolean unwrapProxy, boolean ignoreNotFound, boolean isLogicalOneToOne)
-
ManyToOneType
public ManyToOneType(TypeFactory.TypeScope scope, java.lang.String referencedEntityName, boolean referenceToPrimaryKey, java.lang.String uniqueKeyPropertyName, java.lang.String propertyName, boolean lazy, boolean unwrapProxy, boolean ignoreNotFound, boolean isLogicalOneToOne)
-
ManyToOneType
public ManyToOneType(ManyToOneType original, java.lang.String superTypeEntityName)
-
-
Method Detail
-
isNullable
public boolean isNullable()
- Specified by:
isNullable
in classEntityType
-
getPropertyName
public java.lang.String getPropertyName()
- Overrides:
getPropertyName
in classEntityType
-
isAlwaysDirtyChecked
public boolean isAlwaysDirtyChecked()
Description copied from interface:AssociationType
Do we dirty check this association, even when there are no columns to be updated?
-
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.
-
isLogicalOneToOne
public boolean isLogicalOneToOne()
Description copied from class:EntityType
Is the association modeled here a 1-1 according to the logical moidel?- Overrides:
isLogicalOneToOne
in classEntityType
- Returns:
- True if a 1-1 in the logical model; false otherwise.
-
getColumnSpan
public int getColumnSpan(Mapping mapping) throws MappingException
Description copied from interface:Type
How many columns are used to persist this type. Always the same assqlTypes(mapping).length
- Parameters:
mapping
- The mapping object :/- Returns:
- The number of columns
- Throws:
MappingException
- Generally indicates an issue accessing the passed mapping object.
-
sqlTypes
public int[] sqlTypes(Mapping mapping) throws MappingException
Description copied from interface:Type
Return the JDBC types codes (perTypes
) for the columns mapped by this type. NOTE: The number of elements in this array matches the return fromType.getColumnSpan(org.hibernate.engine.spi.Mapping)
.- Parameters:
mapping
- 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 achar
/Character
would have a dictated length limit of 1; for a string-basedUUID
would have a size limit of 36; etc. NOTE: The number of elements in this array matches the return fromType.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 noType.dictatedSizes(org.hibernate.engine.spi.Mapping)
were given). NOTE: The number of elements in this array matches the return fromType.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.
-
getForeignKeyDirection
public ForeignKeyDirection getForeignKeyDirection()
Description copied from interface:AssociationType
Get the foreign key directionality of this association
-
hydrate
public java.lang.Object hydrate(java.sql.ResultSet rs, java.lang.String[] names, SharedSessionContractImplementor session, java.lang.Object owner) throws HibernateException, java.sql.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 toType.resolve(java.lang.Object, org.hibernate.engine.spi.SharedSessionContractImplementor, 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 interfaceType
- Overrides:
hydrate
in classAbstractType
- Parameters:
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 entity- Returns:
- An entity or collection key, or an actual value.
- Throws:
HibernateException
- An error from Hibernatejava.sql.SQLException
- An error from the JDBC driver- See Also:
Type.resolve(java.lang.Object, org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object)
-
useLHSPrimaryKey
public boolean useLHSPrimaryKey()
Description copied from interface:AssociationType
Is the primary key of the owning entity table to be used in the join?
-
isModified
public boolean isModified(java.lang.Object old, java.lang.Object current, boolean[] checkable, SharedSessionContractImplementor session) throws HibernateException
Description copied from interface:Type
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. This is really only an issue with association types. For most type implementations it is enough to simply delegate toType.isDirty(java.lang.Object, java.lang.Object, org.hibernate.engine.spi.SharedSessionContractImplementor)
here/- Specified by:
isModified
in interfaceType
- Overrides:
isModified
in classAbstractType
- Parameters:
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.- Returns:
- true if the field has been modified
- Throws:
HibernateException
- A problem occurred performing the checking
-
resolve
public java.lang.Object resolve(java.lang.Object value, SharedSessionContractImplementor session, java.lang.Object owner, java.lang.Boolean overridingEager) throws HibernateException
Description copied from interface:Type
The second phase of 2-phase loading. Only really pertinent for entities and collections. Here we resolve the identifier to an entity or collection instance- Specified by:
resolve
in interfaceType
- Overrides:
resolve
in classEntityType
- Parameters:
value
- an identifier or value returned by hydrate()session
- the sessionowner
- the parent entityoverridingEager
- can override eager from the mapping. For example because ofLoadQueryInfluencers
If null, then it does not override. If true or false then it overrides the mapping value.- Returns:
- the given value, or the value associated with the identifier
- Throws:
HibernateException
- An error from Hibernate- See Also:
Type.hydrate(java.sql.ResultSet, java.lang.String[], org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object)
-
disassemble
public java.io.Serializable disassemble(java.lang.Object value, SharedSessionContractImplementor session, java.lang.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 interfaceType
- Overrides:
disassemble
in classAbstractType
- Parameters:
value
- the value to cachesession
- the originating sessionowner
- optional parent entity object (needed for collections)- Returns:
- the disassembled, deep cloned state
- Throws:
HibernateException
- An error from Hibernate
-
assemble
public java.lang.Object assemble(java.io.Serializable oid, SharedSessionContractImplementor session, java.lang.Object owner) throws HibernateException
Description copied from interface:Type
Reconstruct the object from its disassembled state. This method is the reciprocal ofType.disassemble(java.lang.Object, org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object)
- Specified by:
assemble
in interfaceType
- Overrides:
assemble
in classAbstractType
- Parameters:
oid
- the disassembled state from the cachesession
- the originating sessionowner
- the parent entity object- Returns:
- the (re)assembled object
- Throws:
HibernateException
- An error from Hibernate
-
beforeAssemble
public void beforeAssemble(java.io.Serializable oid, SharedSessionContractImplementor session)
Description copied from interface:Type
Called before assembling a query result set from the query cache, to allow batch fetching of entities missing from the second-level cache.- Specified by:
beforeAssemble
in interfaceType
- Overrides:
beforeAssemble
in classAbstractType
- Parameters:
oid
- The keysession
- The originating session
-
toColumnNullness
public boolean[] toColumnNullness(java.lang.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 typemapping
- The mapping abstraction- Returns:
- array indicating column nullness for a value instance
-
isDirty
public boolean isDirty(java.lang.Object old, java.lang.Object current, SharedSessionContractImplementor session) throws HibernateException
Description copied from interface:Type
Should the parent be considered dirty, given both the old and current value?- Specified by:
isDirty
in interfaceType
- Overrides:
isDirty
in classAbstractType
- Parameters:
old
- the old valuecurrent
- the current valuesession
- The session from which the request originated.- Returns:
- true if the field is dirty
- Throws:
HibernateException
- A problem occurred performing the checking
-
isDirty
public boolean isDirty(java.lang.Object old, java.lang.Object current, boolean[] checkable, SharedSessionContractImplementor session) throws HibernateException
Description copied from interface:Type
Should the parent be considered dirty, given both the old and current value?- Parameters:
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.- Returns:
- true if the field is dirty
- Throws:
HibernateException
- A problem occurred performing the checking
-
-