Class ManyToOneType

All Implemented Interfaces:
Serializable, AssociationType, Type

public class ManyToOneType extends EntityType
A many-to-one association to an entity.
See Also:
  • Constructor Details

    • ManyToOneType

      public ManyToOneType(TypeConfiguration typeConfiguration, String referencedEntityName)
      Creates a many-to-one association type with the given referenced entity.
    • ManyToOneType

      public ManyToOneType(TypeConfiguration typeConfiguration, String referencedEntityName, boolean lazy)
      Creates a many-to-one association type with the given referenced entity and the given laziness characteristic
    • ManyToOneType

      public ManyToOneType(TypeConfiguration typeConfiguration, String referencedEntityName, boolean referenceToPrimaryKey, String uniqueKeyPropertyName, String propertyName, boolean lazy, boolean unwrapProxy, boolean ignoreNotFound, boolean isLogicalOneToOne)
    • ManyToOneType

      public ManyToOneType(ManyToOneType original, String superTypeEntityName)
    • ManyToOneType

      public ManyToOneType(String name, TypeConfiguration typeConfiguration)
  • Method Details

    • isNullable

      public boolean isNullable()
      Description copied from class: EntityType
      The nullability of the property.
      Specified by:
      isNullable in class EntityType
      Returns:
      The nullability of the property.
    • getPropertyName

      public String getPropertyName()
      Overrides:
      getPropertyName in class EntityType
    • 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 class EntityType
      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 model?
      Overrides:
      isLogicalOneToOne in class EntityType
      Returns:
      True if a 1-1 in the logical model; false otherwise.
    • getColumnSpan

      public int getColumnSpan(MappingContext mapping) throws MappingException
      Description copied from interface: Type
      How many columns are used to persist this type?

      Always the same as getSqlTypCodes(mappingContext).length.

      Parameters:
      mapping - The mapping Context object MappingContext
      Returns:
      The number of columns
      Throws:
      MappingException - Generally indicates an issue accessing the passed mappingContext object.
    • getSqlTypeCodes

      public int[] getSqlTypeCodes(MappingContext mappingContext) throws MappingException
      Description copied from interface: Type
      Return the JDBC types codes as defined by Types or SqlTypes for the columns mapped by this type.

      The number of elements in this array must match the return from Type.getColumnSpan(MappingContext).

      Parameters:
      mappingContext - The mapping context MappingContext :/
      Returns:
      The JDBC type codes.
      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
    • 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(Object old, 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 the Type.isDirty(Object, Object, 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(Object, Object, SharedSessionContractImplementor).
      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 checkable
      session - The session from which the request originated.
      Returns:
      true if the field has been modified
      Throws:
      HibernateException - A problem occurred performing the checking
    • disassemble

      public Serializable disassemble(Object value, SharedSessionContractImplementor session, Object owner) throws HibernateException
      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.

      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
    • disassemble

      public Serializable disassemble(Object value, SessionFactoryImplementor sessionFactory) throws HibernateException
      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 with Type.assemble(Serializable, SharedSessionContractImplementor, Object).

      Specified by:
      disassemble in interface Type
      Overrides:
      disassemble in class AbstractType
      Parameters:
      value - the value to cache
      sessionFactory - the session factory
      Returns:
      the disassembled, deep cloned state
      Throws:
      HibernateException - An error from Hibernate
    • assemble

      public Object assemble(Serializable oid, SharedSessionContractImplementor session, Object owner) throws HibernateException
      Description copied from interface: Type
      Reconstruct the object from its disassembled state. This function is the inverse of Type.disassemble(Object, SharedSessionContractImplementor, 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
    • beforeAssemble

      public void beforeAssemble(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 interface Type
      Overrides:
      beforeAssemble in class AbstractType
      Parameters:
      oid - The key
      session - The originating session
    • toColumnNullness

      public boolean[] toColumnNullness(Object value, MappingContext mapping)
      Description copied from interface: Type
      Given an instance of the type, return an array of boolean values indicating which mapped columns would be null.
      Parameters:
      value - an instance of the type
      mapping - The mapping context MappingContext
      Returns:
      array indicating column nullness for a value instance
    • isDirty

      public boolean isDirty(Object old, 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 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
      Throws:
      HibernateException - A problem occurred performing the checking
    • isDirty

      public boolean isDirty(Object old, 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 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
      Throws:
      HibernateException - A problem occurred performing the checking