Class NestedTableMapping

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, ContainerMapping

    public class NestedTableMapping
    extends CollectionMapping

    Purpose: Nested tables are similar to VARRAYs except internally they store their information in a separate table from their parent structure's table. The advantage of nested tables is that they support querying and joining much better than varrays that are inlined into the parent table. A nested table is typically used to represent a one-to-many or many-to-many relationship of references to another independent structure. TopLink supports storing a nested table of values into a single field.

    NOTE: Only Oracle8i supports nested tables type.

    See Also:
    Serialized Form
    Since:
    TOPLink/Java 2.5
    • Field Detail

      • field

        protected org.eclipse.persistence.internal.helper.DatabaseField field
        A ref is always stored in a single field.
      • structureName

        protected java.lang.String structureName
        Arrays require a structure name, this is the ADT defined for the VARRAY.
    • Constructor Detail

      • NestedTableMapping

        public NestedTableMapping()
        PUBLIC: Default constructor.
    • Method Detail

      • buildExpression

        public Expression buildExpression​(java.lang.Object queryObject,
                                          QueryByExamplePolicy policy,
                                          Expression expressionBuilder,
                                          java.util.Map processedObjects,
                                          org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: In case Query By Example is used, this method builds and returns an expression that corresponds to a single attribute and it's value.
        Overrides:
        buildExpression in class CollectionMapping
      • clone

        public java.lang.Object clone()
        INTERNAL: The mapping clones itself to create deep copy
        Overrides:
        clone in class CollectionMapping
      • collectFields

        protected java.util.Vector collectFields()
        Returns all the aggregate fields.
        Overrides:
        collectFields in class DatabaseMapping
      • getField

        public org.eclipse.persistence.internal.helper.DatabaseField getField()
        INTERNAL: Returns the field which this mapping represents.
        Overrides:
        getField in class DatabaseMapping
      • getFieldName

        public java.lang.String getFieldName()
        PUBLIC: Return the name of the field this mapping represents.
      • getJoinCriteria

        public Expression getJoinCriteria​(org.eclipse.persistence.internal.expressions.ObjectExpression context,
                                          Expression base)
        INTERNAL: Join criteria is created to read target records (nested table) from the table.
        Overrides:
        getJoinCriteria in class CollectionMapping
      • getStructureName

        public java.lang.String getStructureName()
        PUBLIC: Return the structure name of the nestedTable. This is the name of the user defined data type as defined on the database.
      • hasConstraintDependency

        public boolean hasConstraintDependency()
        INTERNAL: The returns if the mapping has any constraint dependencies, such as foreign keys and join tables.
        Overrides:
        hasConstraintDependency in class DatabaseMapping
      • initializeSelectionCriteria

        protected void initializeSelectionCriteria​(org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Selection criteria is created to read target records (nested table) from the table.
      • setField

        protected void setField​(org.eclipse.persistence.internal.helper.DatabaseField theField)
        Set the field in the mapping.
      • setFieldName

        public void setFieldName​(java.lang.String FieldName)
        PUBLIC: Set the field name in the mapping.
      • setStructureName

        public void setStructureName​(java.lang.String structureName)
        PUBLIC: Set the name of the structure. This is the name of the user defined nested table data type as defined on the database.
      • writeFromObjectIntoRow

        public void writeFromObjectIntoRow​(java.lang.Object object,
                                           org.eclipse.persistence.internal.sessions.AbstractRecord record,
                                           org.eclipse.persistence.internal.sessions.AbstractSession session,
                                           DatabaseMapping.WriteType writeType)
        INTERNAL: Get a value from the object and set that in the respective field of the row.
        Overrides:
        writeFromObjectIntoRow in class DatabaseMapping
      • writeFromObjectIntoRowWithChangeRecord

        public void writeFromObjectIntoRowWithChangeRecord​(org.eclipse.persistence.internal.sessions.ChangeRecord changeRecord,
                                                           org.eclipse.persistence.internal.sessions.AbstractRecord record,
                                                           org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                           DatabaseMapping.WriteType writeType)
        INTERNAL: Get a value from the object and set that in the respective field of the row.
        Overrides:
        writeFromObjectIntoRowWithChangeRecord in class DatabaseMapping
      • writeFromObjectIntoRowForShallowInsert

        public void writeFromObjectIntoRowForShallowInsert​(java.lang.Object object,
                                                           org.eclipse.persistence.internal.sessions.AbstractRecord record,
                                                           org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: This row is built for shallow insert which happens in case of bidirectional inserts. The foreign keys must be set to null to avoid constraints.
        Overrides:
        writeFromObjectIntoRowForShallowInsert in class DatabaseMapping
      • writeFromObjectIntoRowForUpdateAfterShallowInsert

        public void writeFromObjectIntoRowForUpdateAfterShallowInsert​(java.lang.Object object,
                                                                      org.eclipse.persistence.internal.sessions.AbstractRecord record,
                                                                      org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                                      org.eclipse.persistence.internal.helper.DatabaseTable table)
        INTERNAL: This row is built for update after shallow insert which happens in case of bidirectional inserts. It contains the foreign keys with non null values that were set to null for shallow insert.
        Overrides:
        writeFromObjectIntoRowForUpdateAfterShallowInsert in class DatabaseMapping
      • writeFromObjectIntoRowForShallowInsertWithChangeRecord

        public void writeFromObjectIntoRowForShallowInsertWithChangeRecord​(org.eclipse.persistence.internal.sessions.ChangeRecord changeRecord,
                                                                           org.eclipse.persistence.internal.sessions.AbstractRecord record,
                                                                           org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: This row is built for shallow insert which happens in case of bidirectional inserts. The foreign keys must be set to null to avoid constraints.
        Overrides:
        writeFromObjectIntoRowForShallowInsertWithChangeRecord in class DatabaseMapping
      • writeInsertFieldsIntoRow

        public void writeInsertFieldsIntoRow​(org.eclipse.persistence.internal.sessions.AbstractRecord record,
                                             org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Write fields needed for insert into the template for with null values.
        Overrides:
        writeInsertFieldsIntoRow in class DatabaseMapping