SolarMetric Kodo JDO 2.5.8 generated on January 11 2004

com.solarmetric.kodo.impl.jdbc.ormapping
Class FieldMapping

java.lang.Object
  |
  +--com.solarmetric.kodo.impl.jdbc.ormapping.Mapping
        |
        +--com.solarmetric.kodo.impl.jdbc.ormapping.FieldMapping
Direct Known Subclasses:
AbstractCollectionMapping, AbstractMapMapping, LobMapping, OneToOneMapping, ValueMapping

public abstract class FieldMapping
extends Mapping

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


Field Summary
static String COL_INDEX
          Metadata extension key used to mark fields for indexing.
static String COL_LENGTH
          Metadata extension key used to specify the maximum length of a field.
static String DATA_COL
          Metadata extension key used to mark the name of the data column for this field.
protected static Column[] EMPTY_COLUMNS
           
 
Fields inherited from class com.solarmetric.kodo.impl.jdbc.ormapping.Mapping
_loc, _log, CUSTOM_MAPPING, dict, MAPPING, TABLE
 
Constructor Summary
FieldMapping()
           
 
Method Summary
(package private) static Column addColumn(FieldMetaData fmd, DBDictionary dict, Table table, String extName, String defName, String extLen, String extIndex, int type, boolean key)
          Utility method to add a column to the given table.
(package private) static Column[] addPKColumns(ClassMetaData meta, FieldMetaData fmd, JDBCConfiguration conf, Table table, String extName, String defName, ClassResolver resolver, DBDictionary dict)
          Utility method to create columns corresponding to the primary key values of the given metadata.
abstract  void appendIsEmpty(QuerySQLBuffer sql, Joins joins)
          Create a where clause to the given statement asking if this value is empty.
abstract  void appendIsNotNull(QuerySQLBuffer sql, Joins joins)
          Add a where clause to the given statement asking if this value is not null.
abstract  void appendIsNull(QuerySQLBuffer sql, Joins joins)
          Add a where clause to the given statement asking if this value is null.
(package private) abstract  boolean canMap(FieldMetaData fmd, ClassResolver resolver)
          Return true if this mapping type can handle the given field, false otherwise.
 void compareToNull(ObjectSelect sel, boolean isNull)
          Compare this column to null.
 Column[] getDataColumns()
          Return the primary data column(s) for this mapping.
 Object getDataStoreValue(Object val, PersistenceManagerImpl pm)
          Translate the given field value to its datastore equivalent.
static FieldMapping getInstance(FieldMetaData fmd)
          Return the FieldMapping for the given FieldMetaData, creating it if necessary.
static FieldMapping getInstance(FieldMetaData fmd, boolean required)
           
abstract  Column[] getKeyColumns()
          Return the key columns of the mapping.
 Object getKeyDataStoreValue(Object val, PersistenceManagerImpl pm)
          Translate the given key value to its datastore equivalent.
 FieldMetaData getMetaData()
          Return the metadata for the primary data column.
(package private)  void install(FieldMetaData fmd, JDBCConfiguration conf, ClassResolver resolver, DBDictionary dict)
          Setup this FieldMapping using the given metadata.
abstract  void join(Joins joins, PersistenceManagerImpl pm)
          Join this value to the class table.
 void join(ObjectSelect select)
          Join this mapping to the given select statement.
abstract  void joinKey(Joins joins, PersistenceManagerImpl pm)
          Join the key value to the class table.
abstract  void joinKeyRelation(Joins joins, PersistenceManagerImpl pm)
          Join this value's table to the table for the related first class object key type, if any.
abstract  void joinRelation(Joins joins, PersistenceManagerImpl pm)
          Join this value's table to the table for the related first class object type, if any.
abstract  void select(QuerySelect sel)
          Select this mapping.
 void setDataColumns(Column[] data)
          Set the primary data column(s) for this mapping.
 
Methods inherited from class com.solarmetric.kodo.impl.jdbc.ormapping.Mapping
checkExtension, createMapping, createMapping, createMappings, createMappings, getClassName, getConfiguration, getDictionary, getFieldMapping, getInstance, getTable, install
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATA_COL

public static final String DATA_COL
Metadata extension key used to mark the name of the data column for this field.

COL_INDEX

public static final String COL_INDEX
Metadata extension key used to mark fields for indexing.

COL_LENGTH

public static final String COL_LENGTH
Metadata extension key used to specify the maximum length of a field.

EMPTY_COLUMNS

protected static final Column[] EMPTY_COLUMNS
Constructor Detail

FieldMapping

public FieldMapping()
Method Detail

getInstance

public static FieldMapping getInstance(FieldMetaData fmd)
Return the FieldMapping for the given FieldMetaData, creating it if necessary.

getInstance

public static FieldMapping getInstance(FieldMetaData fmd,
                                       boolean required)

getDataColumns

public Column[] getDataColumns()
Return the primary data column(s) for this mapping. This will be the primary key column(s) for object mappings.

setDataColumns

public void setDataColumns(Column[] data)
Set the primary data column(s) for this mapping. For primary table mappings, these columns should reside in the same table as the PK columns of this class. For mappings to other object types, these columns should hold the PK values for the related object.

getMetaData

public FieldMetaData getMetaData()
Return the metadata for the primary data column.

join

public void join(ObjectSelect select)
Join this mapping to the given select statement. For basic mappings, this no-op method implementation will suffice. Secondary table mappings should override this method to do the proper join.

compareToNull

public void compareToNull(ObjectSelect sel,
                          boolean isNull)
Compare this column to null. For basic primary table mappings, the default definition of this method will suffice. More complex mappings should override this method.

canMap

abstract boolean canMap(FieldMetaData fmd,
                        ClassResolver resolver)
Return true if this mapping type can handle the given field, false otherwise. Note that this method cannot rely on the existance of other Mappings, as it is used in bootstrapping.

install

void install(FieldMetaData fmd,
             JDBCConfiguration conf,
             ClassResolver resolver,
             DBDictionary dict)
Setup this FieldMapping using the given metadata. Note that this method cannot rely on the existance of other Mappings, as it it is used in bootstrapping. This base implementation installs the proper extensions onto the metadata only; subclasses must override to properly map the type.

addPKColumns

static Column[] addPKColumns(ClassMetaData meta,
                             FieldMetaData fmd,
                             JDBCConfiguration conf,
                             Table table,
                             String extName,
                             String defName,
                             ClassResolver resolver,
                             DBDictionary dict)
Utility method to create columns corresponding to the primary key values of the given metadata.
Parameters:
meta - the metadata whose pk columns to add
fmd - the field the mapping is being made for
dict - the dictionary of the database in use
table - the table to add to
extName - the metadata etension to check for column names with; if app identity the pk field name will be prepended
defName - the default column name; if app identity the pk field name will be prepended
resolver - the resolver to use for class name resolution.

addColumn

static Column addColumn(FieldMetaData fmd,
                        DBDictionary dict,
                        Table table,
                        String extName,
                        String defName,
                        String extLen,
                        String extIndex,
                        int type,
                        boolean key)
Utility method to add a column to the given table.
Parameters:
fmd - the metadata for the column mapping
dict - the DBDictionary for the database in use
table - the table to add the column to
extName - the metadata extension to check for the column name
defName - the default name if no extension is present
extLen - the metadata extension to check for the column len
extIndex - the metadata extension to check for an index name
type - the SQLType of the column or, if UNKNOWN, this method will form the type from the fmd type and column length
key - if the mapping is for a map key

getDataStoreValue

public Object getDataStoreValue(Object val,
                                PersistenceManagerImpl pm)
Translate the given field value to its datastore equivalent. If the mapping occupies multiple columns in the datastore, return an object array, else return a single object. Simply returns the given object by default.

getKeyDataStoreValue

public Object getKeyDataStoreValue(Object val,
                                   PersistenceManagerImpl pm)
Translate the given key value to its datastore equivalent. If the mapping occupies multiple columns in the datastore, return an object array, else return a single object. Simply returns the given object by default.

select

public abstract void select(QuerySelect sel)
Select this mapping.

getKeyColumns

public abstract Column[] getKeyColumns()
Return the key columns of the mapping.

appendIsEmpty

public abstract void appendIsEmpty(QuerySQLBuffer sql,
                                   Joins joins)
Create a where clause to the given statement asking if this value is empty.

appendIsNull

public abstract void appendIsNull(QuerySQLBuffer sql,
                                  Joins joins)
Add a where clause to the given statement asking if this value is null.

appendIsNotNull

public abstract void appendIsNotNull(QuerySQLBuffer sql,
                                     Joins joins)
Add a where clause to the given statement asking if this value is not null.

join

public abstract void join(Joins joins,
                          PersistenceManagerImpl pm)
Join this value to the class table.

joinKey

public abstract void joinKey(Joins joins,
                             PersistenceManagerImpl pm)
Join the key value to the class table.

joinRelation

public abstract void joinRelation(Joins joins,
                                  PersistenceManagerImpl pm)
Join this value's table to the table for the related first class object type, if any.

joinKeyRelation

public abstract void joinKeyRelation(Joins joins,
                                     PersistenceManagerImpl pm)
Join this value's table to the table for the related first class object key type, if any.

SolarMetric Kodo JDO 2.5.8 generated on January 11 2004

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