Class ClassMapping

    • Field Detail

      • EMPTY_MAPPINGS

        public static final ClassMapping[] EMPTY_MAPPINGS
    • Constructor Detail

      • ClassMapping

        protected ClassMapping​(java.lang.Class type,
                               MappingRepository repos)
        Constructor. Supply described type and owning repository.
      • ClassMapping

        protected ClassMapping​(ValueMetaData vmd)
        Embedded constructor. Supply embedding value and owning repository.
    • Method Detail

      • getDiscriminator

        public Discriminator getDiscriminator()
        The class discriminator.
      • getVersion

        public Version getVersion()
        The version indicator.
      • getObjectId

        public java.lang.Object getObjectId​(JDBCStore store,
                                            Result res,
                                            ForeignKey fk,
                                            boolean subs,
                                            Joins joins)
                                     throws java.sql.SQLException
        Return the oid value stored in the result. This implementation will recurse until it finds an ancestor class who uses oid values for its primary key.
        Parameters:
        fk - if non-null, use the local columns of the given foreign key in place of this class' primary key columns
        Throws:
        java.sql.SQLException
        See Also:
        isPrimaryKeyObjectId(boolean)
      • toDataStoreValue

        public java.lang.Object toDataStoreValue​(java.lang.Object obj,
                                                 Column[] cols,
                                                 JDBCStore store)
        Return the given column value(s) for the given object. The given columns will be primary key columns of this mapping, but may be in any order. If there is only one column, return its value. If there are multiple columns, return an object array of their values, in the same order the columns are given.
      • assertJoinable

        public Joinable assertJoinable​(Column col)
        Return the joinable for the given column, or throw an exception if none is available.
      • getJoinable

        public Joinable getJoinable​(Column col)
        Return the Joinable for the given column. Any column that another mapping joins to must be controlled by a joinable.
      • setJoinable

        public void setJoinable​(Column col,
                                Joinable joinable)
        Add the given column-to-joinable mapping.
      • isForeignKeyObjectId

        public java.lang.Boolean isForeignKeyObjectId​(ForeignKey fk)
        Return whether the columns of the given foreign key to this mapping can be used to construct an object id for this type. This is a relatively expensive operation; its results should be cached.
        Returns:
        Boolean.TRUE if the foreign key contains all oid columns, null if it contains only some columns, or Boolean.FALSE if it contains non-oid columns
      • getStrategy

        public ClassStrategy getStrategy()
        The strategy used to map this mapping.
      • setStrategy

        public void setStrategy​(ClassStrategy strategy,
                                java.lang.Boolean adapt)
        The strategy used to map this mapping. The adapt parameter determines whether to adapt when mapping the strategy; use null if the strategy should not be mapped.
      • getTable

        public Table getTable()
        The mapping's primary table.
      • setTable

        public void setTable​(Table table)
        The mapping's primary table.
      • getPrimaryKeyColumns

        public Column[] getPrimaryKeyColumns()
        The columns this mapping uses to uniquely identify an object. These will typically be the primary key columns or the columns this class uses to link to its superclass table.
      • setPrimaryKeyColumns

        public void setPrimaryKeyColumns​(Column[] cols)
        The columns this mapping uses to uniquely identify an object. These will typically be the primary key columns or the columns this class uses to link to its superclass table.
      • getColumnIO

        public ColumnIO getColumnIO()
        I/O information on the key columns / join key.
      • setColumnIO

        public void setColumnIO​(ColumnIO io)
        I/O information on the key columns / join key.
      • getJoinForeignKey

        public ForeignKey getJoinForeignKey()
        Foreign key linking the primary key columns to the superclass table, or null if none.
      • setJoinForeignKey

        public void setJoinForeignKey​(ForeignKey fk)
        Foreign key linking the primary key columns to the superclass table, or null if none.
      • refSchemaComponents

        public void refSchemaComponents()
      • clearMapping

        public void clearMapping()
        Clear mapping information, including strategy.
      • syncMappingInfo

        public void syncMappingInfo()
        Update MappingInfo with our current mapping information.
      • setDescribedType

        protected void setDescribedType​(java.lang.Class type)
        Description copied from class: ClassMetaData
        Set the class described by this metadata. The type may be reset when an embedded value changes its declared type.
        Overrides:
        setDescribedType in class ClassMetaData
      • getSubclassFetchMode

        public int getSubclassFetchMode()
        The subclass fetch mode, as one of the eager constants in JDBCFetchConfiguration.
      • setSubclassFetchMode

        public void setSubclassFetchMode​(int mode)
        The subclass fetch mode, as one of the eager constants in JDBCFetchConfiguration.
      • isMapped

        public boolean isMapped()
        Returns true if this class does not use the "none" strategy (including if it has a null strategy, and therefore is probably in the process of being mapped).
        Overrides:
        isMapped in class ClassMetaData
      • getJoinablePCSuperclassMapping

        public ClassMapping getJoinablePCSuperclassMapping()
        Return the nearest mapped superclass that can join to this class.
      • getJoinablePCSubclassMappings

        public ClassMapping[] getJoinablePCSubclassMappings()
        Return mapped subclasses that are reachable via joins.
      • getIndependentAssignableMappings

        public ClassMapping[] getIndependentAssignableMappings()
        Returns the closest-derived list of non-inter-joinable mapped types assignable to this type. May return this mapping.
      • resolveMapping

        protected void resolveMapping​(boolean runtime)
        Description copied from class: ClassMetaData
        Resolve mapping data. Logs resolve message and resolves super by default.
        Overrides:
        resolveMapping in class ClassMetaData
      • copy

        public void copy​(ClassMetaData cls)
        Description copied from class: ClassMetaData
        Copy the metadata from the given instance to this one. Do not copy mapping information.
        Overrides:
        copy in class ClassMetaData
      • validateDataStoreExtensionPrefix

        protected boolean validateDataStoreExtensionPrefix​(java.lang.String prefix)
        Description copied from class: Extensions
        Return true if extensions starting with the given official datastore prefix should be validated for this runtime.
        Overrides:
        validateDataStoreExtensionPrefix in class Extensions
      • getAlias

        public java.lang.String getAlias()
        Description copied from interface: Strategy
        Return the alias of this strategy. For custom strategies, return the full class name.
        Specified by:
        getAlias in interface Strategy
      • map

        public void map​(boolean adapt)
        Description copied from interface: Strategy
        Map the owning mapping using this strategy.
        Specified by:
        map in interface Strategy
        Parameters:
        adapt - if true, use the owning mapping's raw mapping info to set its ORM data; if false, ORM data will already be set
      • initialize

        public void initialize()
        Description copied from interface: Strategy
        Perform caching and other initialization operations. This method is called after Strategy.map(boolean), and after all related components have been mapped as well.
        Specified by:
        initialize in interface Strategy
      • insert

        public void insert​(OpenJPAStateManager sm,
                           JDBCStore store,
                           RowManager rm)
                    throws java.sql.SQLException
        Description copied from interface: Strategy
        Set values for the mapping into the proper rows. For class mappings, this method will be called only after the corresponding method has been called for all fields of this mapping.
        Specified by:
        insert in interface Strategy
        Throws:
        java.sql.SQLException
      • customInsert

        public void customInsert​(OpenJPAStateManager sm,
                                 JDBCStore store)
                          throws java.sql.SQLException
        Description copied from interface: Strategy
        Override this method to customize flushing this mapping. For classes, this method must also flush all fields. For fields, this method is called after the owning object is inserted, so if this field is in a row with other fields, that row will already exist.
        Specified by:
        customInsert in interface Strategy
        Throws:
        java.sql.SQLException
      • customUpdate

        public void customUpdate​(OpenJPAStateManager sm,
                                 JDBCStore store)
                          throws java.sql.SQLException
        Description copied from interface: Strategy
        Override this method to customize flushing this mapping. For classes, this method must also flush all fields.
        Specified by:
        customUpdate in interface Strategy
        Throws:
        java.sql.SQLException
      • customDelete

        public void customDelete​(OpenJPAStateManager sm,
                                 JDBCStore store)
                          throws java.sql.SQLException
        Description copied from interface: Strategy
        Override this method to customize flushing this mapping. For classes, this method must also flush all fields. For fields, this method will be called after the owning object is deleted.
        Specified by:
        customDelete in interface Strategy
        Throws:
        java.sql.SQLException
      • isPrimaryKeyObjectId

        public boolean isPrimaryKeyObjectId​(boolean hasAll)
        Description copied from interface: ClassStrategy
        Return true if the this class' primary key columns correspond to the base class' primary key columns used to construct oid values. Base classes always return true. Classes that join to the base class table, though, may not always join using the same columns the base class uses for oid values, or may not use all the columns. When performing a select, we will join down to the most-derived class that is identified by oid values. We cannot use non-primary key field values for joining during selects, because the field values to join on might be the ones we're trying to select! Similarly, we can only reconstruct oid values for selected objects using classes whose primary keys store oid values.
        Specified by:
        isPrimaryKeyObjectId in interface ClassStrategy
        Parameters:
        hasAll - if true, there must be a primary key column for every base class primary key column; if false the primary key must only match a subset of the base class primary key columns
      • joinSuperclass

        public Joins joinSuperclass​(Joins joins,
                                    boolean toThis)
        Description copied from interface: ClassStrategy
        Join the mapping and its superclass.
        Specified by:
        joinSuperclass in interface ClassStrategy
        toThis - if false, inner join to the superclass table; if true, outer join from the superclass table to this table
      • customLoad

        public ResultObjectProvider customLoad​(JDBCStore store,
                                               boolean subclasses,
                                               JDBCFetchConfiguration fetch,
                                               long startIdx,
                                               long endIdx)
                                        throws java.sql.SQLException
        Description copied from interface: ClassStrategy
        Implement this method to customize obtaining a result containing all instances of this class. Return null for standard loading.
        Specified by:
        customLoad in interface ClassStrategy
        Throws:
        java.sql.SQLException
      • customLoad

        public boolean customLoad​(OpenJPAStateManager sm,
                                  JDBCStore store,
                                  PCState state,
                                  JDBCFetchConfiguration fetch)
                           throws java.sql.SQLException,
                                  java.lang.ClassNotFoundException
        Description copied from interface: ClassStrategy
        Implement this method to load the state of a given object, without a previous Result. Return true if this method handles the load. If the object does not exist in the data store, simply take no action on it (but still return true). Return false to use default loading.
        Specified by:
        customLoad in interface ClassStrategy
        state - if non-null, then you must initialize the state and persistent object of the given state manager (after determining the actual class of the object from the database, if there are possible persistent subclasses); initialization looks like this: sm.initialize (pcClass, state)
        Throws:
        java.sql.SQLException
        java.lang.ClassNotFoundException
      • isVerticalStrategy

        public boolean isVerticalStrategy()