Overview | Package | Class | Tree | Serialized | Deprecated | Index | Help
| SolarMetric Kodo JDO 2.4.3 generated on March 27 2003
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.solarmetric.kodo.impl.jdbc.ormapping
Class ClassMapping

    java.lang.Object
      |
      +--com.solarmetric.kodo.impl.jdbc.ormapping.Mapping
            |
            +--com.solarmetric.kodo.impl.jdbc.ormapping.ClassMapping

public class ClassMapping
extends Mapping

A mapping between a java class and its relational database representation.

Field Summary
`static String` | `LOCK_COL` Metadata extension key used to mark the name of the optimistic lock column for this class.
`static String` | `PK_COL` Metadata extension key used to mark the name of the primary key column for this class, if it uses data store identity.
`static String` | `SUBCLASS_PROVIDER` Metadata extension key used to override the default subclass provider setting for this class.

Fields inherited from class com.solarmetric.kodo.impl.jdbc.ormapping.Mapping
`CUSTOM_MAPPING, dict, MAPPING, TABLE`

Constructor Summary
`ClassMapping()`

Method Summary
`protected void` | `addSubclassConditions(PersistenceManagerImpl pm, ObjectSelect sel, FieldMetaData[] fmds, boolean subs)` Adds to the where clause of the given query to only select the desired classes.
`protected void` | `addTableJoins(PersistenceManager pm, ObjectSelect sel)` Adds the appropriate join logic to join together multiple primary tables.
`boolean` | `checkVersion(StateManagerImpl sm, SQLExecutionManager sqlem)` Determine whether the given StateManager is the same version as the datastore version.
`void` | `delete(StateManagerImpl sm, SQLExecutionManager sqlem)` Deletes the given instance from the database.
`boolean` | `exists(PersistenceManagerImpl pm, Object oid, SQLExecutionManager sqlem)` Verify that a given instance exists in the data store.
`Table` | `getDefaultPrimaryTable()` Return the default primary table used by this class.
`static ClassMapping` | `getInstance(ClassMetaData meta)` Return the ClassMapping for the given ClassMetaData instance, or null if none.
`Column` | `getLockColumn()` Return the column used to track the optimistic lock version of the class.
`ClassMetaData` | `getMetaData()` Return the ClassMetaData instance this mapping is installed on.
`Object` | `getObjectId(PersistenceManagerImpl pm, ResultSet rs, int startIndex)` Return the object id for the object stored in the current row of the given result set.
`Column[]` | `getPKColumns()` Return the primary key column(s) of the class' primary table.
`Column[]` | `getPKColumns(Table t)` Return the primary key column(s) for a particular primary table.
`FieldMetaData[]` | `getPrimaryMappingFields(PersistenceManagerImpl pm, boolean subs, ClassResolver resolver, DBDictionary dict, BitSet forcedFields, BitSet excludedFields)` Returns an array of all `FieldMetaData` objects to load when loading primary mappings for this class.
`protected List` | `getPrimaryMappingFields(PersistenceManagerImpl pm, FieldMetaData[] fmds, Set tables, BitSet forcedFields, BitSet excludedFields)` Returns the primary table field meta datas from the given list that are either in the dfg or in the `forcedFields` bit set.
`protected Table` | `getPrimaryTable(FieldMetaData fmd)` Return the primary table used by this class for this field.
`Table[]` | `getPrimaryTables()`
`Class[]` | `getSubclasses()`
`protected Class[]` | `getSubclassesDifferentMapping(ClassResolver resolver)` Return a list of known persistent subclasses of the mapped type that map to more tables than this mapping.
`protected Class[]` | `getSubclassesSameMapping(ClassResolver resolver)` Return a list of known persistent subclasses of the mapped type that map to exactly the same set of tables as this mapping.
`SubclassProvider` | `getSubclassProvider()` Return the `SubclassProvider` responsible for providing subclass services for this mapping.
`void` | `insert(StateManagerImpl sm, SQLExecutionManager sqlem)` Inserts the given instance into the database.
`boolean` | `loadByPK(StateManagerImpl sm, com.solarmetric.kodo.runtime.JDOState state, SQLExecutionManager sqlem, BitSet fields, boolean setVersion, boolean forUpdate)` Load the object referenced by `sm`.
`void` | `loadPrimaryMappings(StateManagerImpl sm, ResultSet rs, FieldMetaData[] fmds, int startIndex, com.solarmetric.kodo.runtime.JDOState state)` Load the primary mappings selected in the `selectPrimaryMappings(com.solarmetric.kodo.runtime.PersistenceManagerImpl, com.solarmetric.kodo.impl.jdbc.sql.ObjectSelect, com.solarmetric.kodo.impl.jdbc.SQLExecutionManager, com.solarmetric.kodo.meta.FieldMetaData[], boolean)` methods into the given StateManager.
`ExtentImpl` | `newExtent(boolean subclasses, JDBCStoreManager store)` Returns an `ExtentImpl` for the class managed by this `ClassMapping`, optionally including subclasses.
`ResultSet` | `selectPrimaryMappings(PersistenceManagerImpl pm, ObjectSelect sel, SQLExecutionManager sqlem, FieldMetaData[] fmds, boolean subs)` Loads the FieldData instances matching the given Select of the type mapped by this ClassMapping from the database.
`void` | `setLockColumn(Column lock)` Set the column used to track the optimistic lock version of the class.
`void` | `setPKColumns(Column[] pks)` Set the primary key column(s) of the class' primary table.
`void` | `setPKColumns(Table t, Column[] pks)` Set the primary key column(s) for the given primary table.
`protected void` | `setSubclasses(Class[] subclasses)` Set the persistent subclasses of this type.
`void` | `update(StateManagerImpl sm, BitSet fields, SQLExecutionManager sqlem)` Updates the given instance in the database.

Methods inherited from class com.solarmetric.kodo.impl.jdbc.ormapping.Mapping
`createMappings, createMappings, getConfiguration, getDictionary, getInstance, getTable`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### PK_COL

    public static final String PK_COL

  Metadata extension key used to mark the name of the primary key column for this class, if it uses data store identity.

### LOCK_COL

    public static final String LOCK_COL

  Metadata extension key used to mark the name of the optimistic lock column for this class.

### SUBCLASS_PROVIDER

    public static final String SUBCLASS_PROVIDER

  Metadata extension key used to override the default subclass provider setting for this class.

Constructor Detail

### ClassMapping

    public ClassMapping()

Method Detail

### getInstance

    public static ClassMapping getInstance(ClassMetaData meta)

  Return the ClassMapping for the given ClassMetaData instance, or null if none.

### getMetaData

    public ClassMetaData getMetaData()

  Return the ClassMetaData instance this mapping is installed on.

### getSubclassProvider

    public SubclassProvider getSubclassProvider()

  Return the `SubclassProvider` responsible for providing subclass services for this mapping.

### getPKColumns

    public Column[] getPKColumns(Table t)

  Return the primary key column(s) for a particular primary table.

### setPKColumns

    public void setPKColumns(Table t,
                             Column[] pks)

  Set the primary key column(s) for the given primary table. The columns must be set in the same order in which the corresponding fields are declared in the persistent class.

### getPKColumns

    public Column[] getPKColumns()

  Return the primary key column(s) of the class' primary table. The columns will be returned in the same order in which the corresponding fields are declared in the persistent class.

### setPKColumns

    public void setPKColumns(Column[] pks)

  Set the primary key column(s) of the class' primary table. The columns must be set in the same order in which the corresponding fields are declared in the persistent class.

### getLockColumn

    public Column getLockColumn()

  Return the column used to track the optimistic lock version of the class.

### setLockColumn

    public void setLockColumn(Column lock)

  Set the column used to track the optimistic lock version of the class. This column must be in the primary table of the class, and must be of an integer type. If the column is not set, the mapped type should not be used in optimistic transactions, as concurrent modification errors will be impossible to detect.

### getSubclasses

    public Class[] getSubclasses()

### getSubclassesSameMapping

    protected Class[] getSubclassesSameMapping(ClassResolver resolver)

  Return a list of known persistent subclasses of the mapped type that map to exactly the same set of tables as this mapping.

### getSubclassesDifferentMapping

    protected Class[] getSubclassesDifferentMapping(ClassResolver resolver)

  Return a list of known persistent subclasses of the mapped type that map to more tables than this mapping.

### setSubclasses

    protected void setSubclasses(Class[] subclasses)

  Set the persistent subclasses of this type. This will merge the list of currently known subclasses with the specified list of subclasses.

### getPrimaryTable

    protected Table getPrimaryTable(FieldMetaData fmd)

  Return the primary table used by this class for this field. This method is not particularly fast, so it should only be used during install if at all possible.

### getPrimaryTables

    public Table[] getPrimaryTables()

### getDefaultPrimaryTable

    public Table getDefaultPrimaryTable()

  Return the default primary table used by this class.

### insert

    public void insert(StateManagerImpl sm,
                       SQLExecutionManager sqlem)
                throws SQLException

  Inserts the given instance into the database.
  Parameters:
    `sm` - The `StateManagerImpl` to insert.
    `sqlem` - The `SQLExecutionManager` to use for executing queries against the data store. For optimal performance, the proprietary `SQLExecutionManager` APIs should be used to execute SQL statements, but it is also possible to obtain the current `Connection` from a `SQLExecutionManager` and use regular JDBC APIs to perform the necessary work.

### update

    public void update(StateManagerImpl sm,
                       BitSet fields,
                       SQLExecutionManager sqlem)
                throws SQLException

  Updates the given instance in the database.
  Parameters:
    `sm` - The `StateManagerImpl` to update.
    `fields` - The fields that need to be stored.
    `sqlem` - The `SQLExecutionManager` to use for executing queries against the data store. For optimal performance, the proprietary `SQLExecutionManager` APIs should be used to execute SQL statements, but it is also possible to obtain the current `Connection` from a `SQLExecutionManager` and use regular JDBC APIs to perform the necessary work.

### delete

    public void delete(StateManagerImpl sm,
                       SQLExecutionManager sqlem)
                throws SQLException

  Deletes the given instance from the database.
  Parameters:
    `sm` - The `StateManagerImpl` to delete.
    `sqlem` - The `SQLExecutionManager` to use for executing queries against the data store. For optimal performance, the proprietary `SQLExecutionManager` APIs should be used to execute SQL statements, but it is also possible to obtain the current `Connection` from a `SQLExecutionManager` and use regular JDBC APIs to perform the necessary work.

### exists

    public boolean exists(PersistenceManagerImpl pm,
                          Object oid,
                          SQLExecutionManager sqlem)
                   throws SQLException

  Verify that a given instance exists in the data store.
  Parameters:
    `pm` - The `PersistenceManagerImpl` that caused this method invocation to be made.
    `oid` - The ID of the object to look for in the data store.
    `sqlem` - The `SQLExecutionManager` to use for executing queries against the data store. For optimal performance, the proprietary `SQLExecutionManager` APIs should be used to execute SQL statements, but it is also possible to obtain the current `Connection` from a `SQLExecutionManager` and use regular JDBC APIs to perform the necessary work.
  Returns:
    `true` if the data exists; else `false`.

### checkVersion

    public boolean checkVersion(StateManagerImpl sm,
                                SQLExecutionManager sqlem)
                         throws SQLException

  Determine whether the given StateManager is the same version as the datastore version.
  Parameters:
    `sm` - the instance for which a version check should be performed.
    `sqlem` - The `SQLExecutionManager` to use for executing queries against the data store. For optimal performance, the proprietary `SQLExecutionManager` APIs should be used to execute SQL statements, but it is also possible to obtain the current `Connection` from a `SQLExecutionManager` and use regular JDBC APIs to perform the necessary work.
  Returns:
    true if the instance is up-to-date, false otherwise

### getObjectId

    public Object getObjectId(PersistenceManagerImpl pm,
                              ResultSet rs,
                              int startIndex)
                       throws SQLException

  Return the object id for the object stored in the current row of the given result set.
  Parameters:
    `store` - the `JDBCStoreManager` making the request for PK values.
    `rs` - the ResultSet produced by the `selectPrimaryMappings(com.solarmetric.kodo.runtime.PersistenceManagerImpl, com.solarmetric.kodo.impl.jdbc.sql.ObjectSelect, com.solarmetric.kodo.impl.jdbc.SQLExecutionManager, com.solarmetric.kodo.meta.FieldMetaData[], boolean)` method
    `startIndex` - the column index that represents the beginning of the SELECTs made in the `selectPrimaryMappings(com.solarmetric.kodo.runtime.PersistenceManagerImpl, com.solarmetric.kodo.impl.jdbc.sql.ObjectSelect, com.solarmetric.kodo.impl.jdbc.SQLExecutionManager, com.solarmetric.kodo.meta.FieldMetaData[], boolean)` method

### loadByPK

    public boolean loadByPK(StateManagerImpl sm,
                            com.solarmetric.kodo.runtime.JDOState state,
                            SQLExecutionManager sqlem,
                            BitSet fields,
                            boolean setVersion,
                            boolean forUpdate)
                     throws SQLException

  Load the object referenced by `sm`.
  Parameters:
    `sm` - The `StateManagerImpl` of the data to load. `sm.oid` contains the object ID of the data.
    `state` - The `JDOState` that `sm` should be initialized to. This can be `null` if no initialization should be performed on `sm`. If non-`null`, then `StateManagerImpl.initialize(javax.jdo.spi.PersistenceCapable, com.solarmetric.kodo.runtime.JDOState)` should be invoked on `sm`.
    `sqlem` - The `SQLExecutionManager` to use for executing queries against the data store. For optimal performance, the proprietary `SQLExecutionManager` APIs should be used to execute SQL statements, but it is also possible to obtain the current `Connection` from a `SQLExecutionManager` and use regular JDBC APIs to perform the necessary work.
    `fields` - A `BitSet` indicating which fields must be loaded. It is legal to load more than just these fields, but at least these must be loaded.
    `forUpdate` - If this is `true`, then the SELECT statement created should request a lock on the selected data.

### newExtent

    public ExtentImpl newExtent(boolean subclasses,
                                JDBCStoreManager store)

  Returns an `ExtentImpl` for the class managed by this `ClassMapping`, optionally including subclasses.
  Parameters:
    `subclasses` - If `true`, the created extent should be capable of accessing all subclasses of the class managed by this `ClassMapping`. Otherwise, the created extent should only provide access to the exact managed class.
    `store` - The `JDBCStoreManager` that made the request for the extent.

### loadPrimaryMappings

    public void loadPrimaryMappings(StateManagerImpl sm,
                                    ResultSet rs,
                                    FieldMetaData[] fmds,
                                    int startIndex,
                                    com.solarmetric.kodo.runtime.JDOState state)
                             throws SQLException

  Load the primary mappings selected in the `selectPrimaryMappings(com.solarmetric.kodo.runtime.PersistenceManagerImpl, com.solarmetric.kodo.impl.jdbc.sql.ObjectSelect, com.solarmetric.kodo.impl.jdbc.SQLExecutionManager, com.solarmetric.kodo.meta.FieldMetaData[], boolean)` methods into the given StateManager.
  Parameters:
    `rs` - the ResultSet produced by the `selectPrimaryMappings(com.solarmetric.kodo.runtime.PersistenceManagerImpl, com.solarmetric.kodo.impl.jdbc.sql.ObjectSelect, com.solarmetric.kodo.impl.jdbc.SQLExecutionManager, com.solarmetric.kodo.meta.FieldMetaData[], boolean)` method
    `startIndex` - the column index that represents the beginning of the SELECTs made in the `selectPrimaryMappings(com.solarmetric.kodo.runtime.PersistenceManagerImpl, com.solarmetric.kodo.impl.jdbc.sql.ObjectSelect, com.solarmetric.kodo.impl.jdbc.SQLExecutionManager, com.solarmetric.kodo.meta.FieldMetaData[], boolean)` method
    `state` - The JDOState that `sm` should be initialized to. Should be `null` if no initialization should happen.

### getPrimaryMappingFields

    public FieldMetaData[] getPrimaryMappingFields(PersistenceManagerImpl pm,
                                                   boolean subs,
                                                   ClassResolver resolver,
                                                   DBDictionary dict,
                                                   BitSet forcedFields,
                                                   BitSet excludedFields)

  Returns an array of all `FieldMetaData` objects to load when loading primary mappings for this class.

### getPrimaryMappingFields

    protected List getPrimaryMappingFields(PersistenceManagerImpl pm,
                                           FieldMetaData[] fmds,
                                           Set tables,
                                           BitSet forcedFields,
                                           BitSet excludedFields)

  Returns the primary table field meta datas from the given list that are either in the dfg or in the `forcedFields` bit set.

### selectPrimaryMappings

    public ResultSet selectPrimaryMappings(PersistenceManagerImpl pm,
                                           ObjectSelect sel,
                                           SQLExecutionManager sqlem,
                                           FieldMetaData[] fmds,
                                           boolean subs)
                                    throws SQLException

  Loads the FieldData instances matching the given Select of the type mapped by this ClassMapping from the database.

### addSubclassConditions

    protected void addSubclassConditions(PersistenceManagerImpl pm,
                                         ObjectSelect sel,
                                         FieldMetaData[] fmds,
                                         boolean subs)

  Adds to the where clause of the given query to only select the desired classes.

### addTableJoins

    protected void addTableJoins(PersistenceManager pm,
                                 ObjectSelect sel)

  Adds the appropriate join logic to join together multiple primary tables.

Overview | Package | Class | Tree | Serialized | Deprecated | Index | Help
| SolarMetric Kodo JDO 2.4.3 generated on March 27 2003
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2001,2002 SolarMetric, Inc. All Rights Reserved.