kodo.jdbc.meta
Class TransformationFieldMapping
java.lang.Object
|
+--kodo.meta.DelegatingExtensions
|
+--kodo.meta.DelegatingFieldMetaData
|
+--kodo.jdbc.meta.AbstractFieldMapping
|
+--kodo.jdbc.meta.ReferenceFieldMapping
|
+--kodo.jdbc.meta.ColumnFieldMapping
|
+--kodo.jdbc.meta.TransformationFieldMapping
- All Implemented Interfaces:
- Commentable, Comparable, Extensions, FieldMapping, FieldMetaData, JDBCTypes, JDOTypes, JoinableMapping, Mapping, VersionableFieldMapping
- public abstract class TransformationFieldMapping
- extends ColumnFieldMapping
- implements JoinableMapping, VersionableFieldMapping
Easily-extendable mapping for transforming a field value from one
simple type to another. For example, an female
field in the
Java class might store a boolean, but it is mapped to a GENDER
column that stores a M
or F
character.
To create a concrete subclass of this mapping, define the following
methods:
Fields inherited from interface kodo.jdbc.meta.JDBCTypes |
TYPE_ASCII_STREAM, TYPE_BINARY_STREAM, TYPE_BLOB, TYPE_BYTES, TYPE_CHAR_STREAM, TYPE_CLOB, TYPE_JDBC_DEFAULT, TYPE_REF, TYPE_SQL_ARRAY, TYPE_SQL_DATE, TYPE_SQL_OBJECT, TYPE_TIME, TYPE_TIMESTAMP |
Fields inherited from interface kodo.meta.JDOTypes |
TYPE_ARRAY, TYPE_BIGDECIMAL, TYPE_BIGINTEGER, TYPE_BOOLEAN, TYPE_BOOLEAN_OBJ, TYPE_BYTE, TYPE_BYTE_OBJ, TYPE_CHAR, TYPE_CHAR_OBJ, TYPE_COLLECTION, TYPE_DATE, TYPE_DOUBLE, TYPE_DOUBLE_OBJ, TYPE_FCO, TYPE_FLOAT, TYPE_FLOAT_OBJ, TYPE_INT, TYPE_INT_OBJ, TYPE_LOCALE, TYPE_LONG, TYPE_LONG_OBJ, TYPE_MAP, TYPE_NUMBER, TYPE_OBJECT, TYPE_PC_OBJECT, TYPE_SHORT, TYPE_SHORT_OBJ, TYPE_STRING |
Fields inherited from interface kodo.jdbc.meta.FieldMapping |
AUTO_INCREMENT, DELETE_ACTION, ELEMENT_DELETE_ACTION, ELEMENT_INDEXED, ELEMENT_SIZE, EXTENSION_KEYS, FIELD_MAP, INDEXED, JDBC_TYPE, KEY_DELETE_ACTION, KEY_INDEXED, KEY_SIZE, REF_DELETE_ACTION, REF_INDEXED, SIZE, SQL_TYPE, VALUE_DELETE_ACTION, VALUE_INDEXED, VALUE_SIZE |
Fields inherited from interface kodo.meta.FieldMetaData |
DEPENDENT, EAGER_FETCH_MODE, ELEMENT_DEPENDENT, ELEMENT_TYPE, EXTERNAL_VALUES, EXTERNALIZER, FACTORY, FETCH_GROUP, INVERSE_LOGICAL, INVERSE_OWNER, KEY_DEPENDENT, KEY_TYPE, LOCK_GROUP, LOCK_GROUP_DEFAULT, LOCK_GROUP_NONE, LRS, MANAGE_NONE, MANAGE_PERSISTENT, MANAGE_TRANSACTIONAL, NULL_DEFAULT, NULL_EXCEPTION, NULL_NONE, NULL_UNSET, SEQUENCE_ASSIGNED, TYPE, VALUE_DEPENDENT, VALUE_TYPE |
Method Summary |
FieldMapping |
getFieldMapping()
Return the field mapping that owns this mapping's columns. |
protected abstract Object |
getJavaValue(Object val)
Transform the given database value to the value that should be
stored in the Java field for this mapping. |
int |
getJoinTypeCode(Column col)
Return the type code from JDBCTypes of the JDBC
value returned from calls to getJoinValue(kodo.jdbc.sql.Result, kodo.jdbc.schema.Column[], kodo.jdbc.schema.ForeignKey, kodo.jdbc.sql.Joins) for the
given column. |
Object |
getJoinValue(Object fieldVal,
Column col)
Return the join value of the given column. |
Object |
getJoinValue(Result res,
Column[] cols,
ForeignKey fk,
Joins joins)
Return the value for this mapping from the given result, using the
given columns. |
void |
load(KodoStateManager sm,
JDBCStoreManager store,
JDBCFetchConfiguration fetch,
Result res)
Load virtual row data; the given result is not guaranteed to contain
data for this field, so the field mapping should make sure the
result contains its needed column data before loading. |
Object |
loadProjection(JDBCStoreManager store,
JDBCFetchConfiguration fetch,
Result res,
Joins joins)
Load this field value using the given result. |
void |
setAutoIncrementValue(KodoStateManager sm,
Column col,
long autoInc)
Use the given auto-incremented value to set this join value's field
on the given instance. |
protected void |
update(KodoStateManager sm,
Row row)
Update this column with the current value into the given row. |
void |
where(KodoStateManager sm,
RowManager rm,
Object prevValue)
Add a WHERE condition to the row for this field such that the field's
current DB value must equal the given previous value. |
Methods inherited from class kodo.jdbc.meta.ColumnFieldMapping |
addMappingInfoAttributes, appendIsNotNull, appendIsNull, checkNull, deleteEmbedded, fromMappingInfo, getColumn, getColumns, getDataStoreTypeCode, getJDBCType, insert, join, load, map, nullEmbedded, refSchemaComponents, select, setColumn, toMappingInfo, update |
Methods inherited from class kodo.jdbc.meta.ReferenceFieldMapping |
createRefForeignKey, delete, fromMappingInfo, getJoinedRow, getRefForeignKey, getRefJoins, getRefJoinType, getTable, join, setRefForeignKey, setRefForeignKey, setRefJoinType, wherePrimaryKey, whereRefForeignKey |
Methods inherited from class kodo.jdbc.meta.AbstractFieldMapping |
addExtensionKeys, appendIsEmpty, assertTable, delete, deleteEmbedded, getDataStoreValue, getDBDictionary, getDeclaredElementTypeMapping, getDeclaredElementTypeMetaData, getDeclaredKeyTypeMapping, getDeclaredKeyTypeMetaData, getDeclaredTypeMapping, getDeclaredTypeMetaData, getDeleteAction, getElementDeleteAction, getElementIndexed, getElementSize, getElementTypeMapping, getElementTypeMetaData, getFieldMappingName, getIndexed, getInverseMappings, getInverseMetaDatas, getInverseOwnerMapping, getInverseOwnerMetaData, getJDBCTypeCode, getKeyColumns, getKeyDataStoreValue, getKeyDeleteAction, getKeyIndexed, getKeySize, getKeyTypeMapping, getKeyTypeMetaData, getMappingRepository, getMetaData, getNonVirtualOwner, getOwner, getOwnerMapping, getOwnerTable, getRefDeleteAction, getRefIndexed, getSize, getSQLType, getTypeMapping, getTypeMetaData, insert, invalidateResolve, isAutoIncrement, isCustomDelete, isCustomDeleteEmbedded, isCustomInsert, isCustomNullEmbedded, isCustomUpdate, isDeleteActionDeferred, isEagerJoinToMany, isElementDeleteActionDeferred, isKeyDeleteActionDeferred, isPCObjectRelation, isRefDeleteActionDeferred, isResolved, joinKey, joinKeyRelation, joinRelation, loadEagerJoin, loadEagerParallel, loadKeyProjection, nullEmbedded, resolve, reverseMap, selectEagerJoin, selectEagerParallel, setAutoIncrement, setDeleteAction, setElementDeleteAction, setElementIndexed, setElementSize, setFieldMappingName, setIndexed, setJDBCTypeCode, setKeyDeleteAction, setKeyIndexed, setKeySize, setNonVirtualOwner, setOwner, setRefDeleteAction, setRefIndexed, setSize, setSQLType, supportsSelect, update, usesImplData, usesIntermediate |
Methods inherited from class kodo.meta.DelegatingFieldMetaData |
compareTo, equals, getComments, getComparator, getDeclaredElementType, getDeclaredElementTypeCode, getDeclaredIndex, getDeclaredKeyType, getDeclaredKeyTypeCode, getDeclaredPrimaryKeyIndex, getDeclaredType, getDeclaredTypeCode, getDelegate, getEagerFetchMode, getElementType, getElementTypeCode, getElementTypeName, getExternalizer, getExternalValue, getExternalValues, getFactory, getFetchGroup, getFieldFlag, getFieldValue, getFullName, getIndex, getInnermostDelegate, getInverseLogical, getInverseOwner, getKeyType, getKeyTypeCode, getKeyTypeName, getListingIndex, getLockGroup, getManagement, getName, getNullValue, getPrimaryKeyIndex, getProxyType, getType, getTypeCode, getTypeName, hashCode, isDefaultFetchGroupExplicit, isDependent, isElementDependent, isElementEmbedded, isEmbedded, isExplicit, isExternalized, isInDefaultFetchGroup, isKeyDependent, isKeyEmbedded, isLRS, isPrimaryKey, isSequenceAssigned, isTransient, setComparator, setDeclaredElementType, setDeclaredElementTypeCode, setDeclaredIndex, setDeclaredKeyType, setDeclaredKeyTypeCode, setDeclaredPrimaryKeyIndex, setDeclaredType, setDeclaredTypeCode, setDependent, setEagerFetchMode, setElementDependent, setElementEmbedded, setElementTypeName, setEmbedded, setExplicit, setExternalizer, setExternalValues, setFactory, setFetchGroup, setInDefaultFetchGroup, setIndex, setInverseLogical, setInverseOwner, setKeyDependent, setKeyEmbedded, setKeyTypeName, setListingIndex, setLockGroup, setLRS, setManagement, setName, setNullValue, setPrimaryKey, setProxyType, setSequenceAssigned, setTransient, setTypeName, toString |
Methods inherited from class kodo.meta.DelegatingExtensions |
addExtension, addExtension, getBooleanExtension, getBooleanExtension, getDoubleExtension, getDoubleExtension, getEmbeddedExtensions, getEmbeddedExtensions, getExtensionComments, getExtensionKeys, getExtensionKeys, getExtensionVendors, getIntExtension, getIntExtension, getObjectExtension, getObjectExtension, getStringExtension, getStringExtension, hasExtension, hasExtension, isEmpty, removeEmbeddedExtensions, removeEmbeddedExtensions, removeExtension, removeExtension |
Methods inherited from interface kodo.meta.FieldMetaData |
getComparator, getDeclaredElementType, getDeclaredElementTypeCode, getDeclaredIndex, getDeclaredKeyType, getDeclaredKeyTypeCode, getDeclaredPrimaryKeyIndex, getDeclaredType, getDeclaredTypeCode, getEagerFetchMode, getElementType, getElementTypeCode, getElementTypeName, getExternalizer, getExternalValue, getExternalValues, getFactory, getFetchGroup, getFieldFlag, getFieldValue, getFullName, getIndex, getInverseLogical, getInverseOwner, getKeyType, getKeyTypeCode, getKeyTypeName, getListingIndex, getLockGroup, getManagement, getName, getNullValue, getPrimaryKeyIndex, getProxyType, getType, getTypeCode, getTypeName, isDefaultFetchGroupExplicit, isDependent, isElementDependent, isElementEmbedded, isEmbedded, isExplicit, isExternalized, isInDefaultFetchGroup, isKeyDependent, isKeyEmbedded, isLRS, isPrimaryKey, isSequenceAssigned, isTransient, setComparator, setDeclaredElementType, setDeclaredElementTypeCode, setDeclaredIndex, setDeclaredKeyType, setDeclaredKeyTypeCode, setDeclaredPrimaryKeyIndex, setDeclaredType, setDeclaredTypeCode, setDependent, setEagerFetchMode, setElementDependent, setElementEmbedded, setElementTypeName, setEmbedded, setExplicit, setExternalizer, setExternalValues, setFactory, setFetchGroup, setInDefaultFetchGroup, setIndex, setInverseLogical, setInverseOwner, setKeyDependent, setKeyEmbedded, setKeyTypeName, setListingIndex, setLockGroup, setLRS, setManagement, setName, setNullValue, setPrimaryKey, setProxyType, setSequenceAssigned, setTransient, setTypeName |
Methods inherited from interface kodo.meta.Extensions |
addExtension, addExtension, getBooleanExtension, getBooleanExtension, getDoubleExtension, getDoubleExtension, getEmbeddedExtensions, getEmbeddedExtensions, getExtensionComments, getExtensionKeys, getExtensionKeys, getExtensionVendors, getIntExtension, getIntExtension, getObjectExtension, getObjectExtension, getStringExtension, getStringExtension, hasExtension, hasExtension, isEmpty, removeEmbeddedExtensions, removeEmbeddedExtensions, removeExtension, removeExtension |
TransformationFieldMapping
public TransformationFieldMapping(FieldMetaData meta)
- Constructor. Supply underlying metadata.
getJavaValue
protected abstract Object getJavaValue(Object val)
- Transform the given database value to the value that should be
stored in the Java field for this mapping. If the Java field
is a primitive, make sure not to return null.
update
protected void update(KodoStateManager sm,
Row row)
throws SQLException
- Description copied from class:
ColumnFieldMapping
- Update this column with the current value into the given row.
- Overrides:
update
in class ColumnFieldMapping
load
public void load(KodoStateManager sm,
JDBCStoreManager store,
JDBCFetchConfiguration fetch,
Result res)
throws SQLException
- Description copied from interface:
FieldMapping
- Load virtual row data; the given result is not guaranteed to contain
data for this field, so the field mapping should make sure the
result contains its needed column data before loading.
loadProjection
public Object loadProjection(JDBCStoreManager store,
JDBCFetchConfiguration fetch,
Result res,
Joins joins)
throws SQLException
- Description copied from interface:
FieldMapping
- Load this field value using the given result. This method will only
be called if this field does not represent a FCO relation. The result
will contain the columns from
FieldMapping.getColumns()
.
where
public void where(KodoStateManager sm,
RowManager rm,
Object prevValue)
throws SQLException
- Description copied from interface:
VersionableFieldMapping
- Add a WHERE condition to the row for this field such that the field's
current DB value must equal the given previous value.
- Specified by:
where
in interface VersionableFieldMapping
getFieldMapping
public FieldMapping getFieldMapping()
- Description copied from interface:
JoinableMapping
- Return the field mapping that owns this mapping's columns. If this
is a delegate mapping, return the field mapping of the delegate.
- Specified by:
getFieldMapping
in interface JoinableMapping
getJoinValue
public Object getJoinValue(Result res,
Column[] cols,
ForeignKey fk,
Joins joins)
throws SQLException
- Description copied from interface:
JoinableMapping
- Return the value for this mapping from the given result, using the
given columns. Outside code will always call this method with
the
cols
array from JoinableMapping.getColumns()
, but delegates
may change the columns to use. If the given foreign key is non-null,
use the foreign key's columns by translating the given columns through
ForeignKey.getColumn(kodo.jdbc.schema.Column)
.
- Specified by:
getJoinValue
in interface JoinableMapping
getJoinValue
public Object getJoinValue(Object fieldVal,
Column col)
- Description copied from interface:
JoinableMapping
- Return the join value of the given column.
- Specified by:
getJoinValue
in interface JoinableMapping
- Following copied from interface:
kodo.jdbc.meta.JoinableMapping
- Parameters:
val
- the value of the field for this mappingcol
- the column of this mapping whose value to return
getJoinTypeCode
public int getJoinTypeCode(Column col)
- Description copied from interface:
JoinableMapping
- Return the type code from
JDBCTypes
of the JDBC
value returned from calls to JoinableMapping.getJoinValue(kodo.jdbc.sql.Result, kodo.jdbc.schema.Column[], kodo.jdbc.schema.ForeignKey, kodo.jdbc.sql.Joins)
for the
given column.
- Specified by:
getJoinTypeCode
in interface JoinableMapping
setAutoIncrementValue
public void setAutoIncrementValue(KodoStateManager sm,
Column col,
long autoInc)
- Description copied from interface:
JoinableMapping
- Use the given auto-incremented value to set this join value's field
on the given instance.
- Specified by:
setAutoIncrementValue
in interface JoinableMapping
Copyright 2001,2002 SolarMetric, Inc. All Rights Reserved.