org.jpox.store.mapping
Class SingleFieldMapping

java.lang.Object
  extended byorg.jpox.store.mapping.JavaTypeMapping
      extended byorg.jpox.store.mapping.SingleFieldMapping
Direct Known Subclasses:
AbstractContainerMapping, BaseStringMapping, BigDecimalMapping, BigIntegerMapping, BitSetMapping, BooleanMapping, BufferedImageMapping, ByteMapping, CharacterMapping, CurrencyMapping, DiscriminatorMapping, DoubleMapping, EmbeddedMapping, FloatMapping, IndexMapping, IntegerMapping, LocaleMapping, LongMapping, NullMapping, OIDMapping, SerialisedMapping, ShortMapping, SqlDateMapping, SqlTimeMapping, SqlTimestampMapping, TimeZoneMapping, URIMapping, URLMapping, VersionMapping

public abstract class SingleFieldMapping
extends JavaTypeMapping

Simple mapping for a java field mapping to a single datastore field.

Version:
$Revision: 1.17 $

Field Summary
protected  DatastoreContainerObject datastoreContainer
           
protected  TypeInfo typeInfo
           
 
Fields inherited from class org.jpox.store.mapping.JavaTypeMapping
datastoreMappings, dba, fmd, LOCALISER, referenceMapping, type
 
Constructor Summary
SingleFieldMapping(DatastoreAdapter dba, AbstractPropertyMetaData fmd, DatastoreContainerObject datastoreContainer)
          Constructor.
SingleFieldMapping(DatastoreAdapter dba, FieldMetaData fmd, DatastoreContainerObject datastoreContainer, boolean initDatastoreMappings)
          Constructor.
SingleFieldMapping(DatastoreAdapter dba, java.lang.String type)
          Constructor.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Equality operator
 boolean getBoolean(PersistenceManager pm, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
 byte getByte(PersistenceManager pm, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
 char getChar(PersistenceManager pm, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
 DatastoreContainerObject getDatastoreContainer()
          Accessor for the datastore class (e.g in an RDBMS context, the Table)
 double getDouble(PersistenceManager pm, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
 float getFloat(PersistenceManager pm, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
 int getInt(PersistenceManager pm, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
 long getLong(PersistenceManager pm, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
 java.lang.Object getObject(PersistenceManager pm, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
 short getShort(PersistenceManager pm, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
 java.lang.String getString(PersistenceManager pm, java.lang.Object resultSet, int[] exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
 boolean hasValue()
          Acccessor for whether the fixed value is set.
 boolean includeInFetchStatement()
          Accessor for the string to put in any retrieval datastore statement for this field.
 boolean includeInInsertStatement()
          This mapping is included in the insert statement.
 boolean includeInUpdateStatement()
          This mapping is included in the update statement.
protected  void prepareDatastoreMapping()
          Method to prepare a field mapping for use in the datastore.
 void setBoolean(PersistenceManager pm, java.lang.Object preparedStatement, int[] exprIndex, boolean value)
          Sets a value into preparedStatement at position specified by exprIndex.
 void setByte(PersistenceManager pm, java.lang.Object preparedStatement, int[] exprIndex, byte value)
          Sets a value into preparedStatement at position specified by exprIndex.
 void setChar(PersistenceManager pm, java.lang.Object preparedStatement, int[] exprIndex, char value)
          Sets a value into preparedStatement at position specified by exprIndex.
 void setDouble(PersistenceManager pm, java.lang.Object preparedStatement, int[] exprIndex, double value)
          Sets a value into preparedStatement at position specified by exprIndex.
 void setFloat(PersistenceManager pm, java.lang.Object preparedStatement, int[] exprIndex, float value)
          Sets a value into preparedStatement at position specified by exprIndex.
 void setInt(PersistenceManager pm, java.lang.Object preparedStatement, int[] exprIndex, int value)
          Sets a value into preparedStatement at position specified by exprIndex.
 void setLong(PersistenceManager pm, java.lang.Object preparedStatement, int[] exprIndex, long value)
          Sets a value into preparedStatement at position specified by exprIndex.
 void setObject(PersistenceManager pm, java.lang.Object preparedStatement, int[] exprIndex, java.lang.Object value)
          Sets a value into preparedStatement at position specified by exprIndex.
 void setShort(PersistenceManager pm, java.lang.Object preparedStatement, int[] exprIndex, short value)
          Sets a value into preparedStatement at position specified by exprIndex.
 void setString(PersistenceManager pm, java.lang.Object preparedStatement, int[] exprIndex, java.lang.String value)
          Sets a value into preparedStatement at position specified by exprIndex.
 
Methods inherited from class org.jpox.store.mapping.JavaTypeMapping
addDataStoreMapping, failureMessage, getDataStoreMapping, getDataStoreMappings, getFieldMetaData, getJavaType, getNumberOfDatastoreFields, getObject, getReferenceMapping, getSampleValue, getType, isNullable, newLiteral, newScalarExpression, setDefault, setObject, setReferenceMapping
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

typeInfo

protected TypeInfo typeInfo

datastoreContainer

protected DatastoreContainerObject datastoreContainer
Constructor Detail

SingleFieldMapping

public SingleFieldMapping(DatastoreAdapter dba,
                          java.lang.String type)
Constructor.

Parameters:
dba - Datastore Adapter
type - Type of the field

SingleFieldMapping

public SingleFieldMapping(DatastoreAdapter dba,
                          AbstractPropertyMetaData fmd,
                          DatastoreContainerObject datastoreContainer)
Constructor.

Parameters:
dba - Datastore Adapter
fmd - AbstractPropertyMetaData for the field being mapped
datastoreContainer - Table containing the mapped object

SingleFieldMapping

public SingleFieldMapping(DatastoreAdapter dba,
                          FieldMetaData fmd,
                          DatastoreContainerObject datastoreContainer,
                          boolean initDatastoreMappings)
Constructor.

Parameters:
dba - Datastroe Adapter
fmd - FieldMetaData for the field to be mapped
datastoreContainer - Table containing the mapped field
initDatastoreMappings - Whether to initialise the datastore mappings (create the columns etc)
Method Detail

hasValue

public boolean hasValue()
Acccessor for whether the fixed value is set.

Returns:
Whether the value is set

prepareDatastoreMapping

protected void prepareDatastoreMapping()
Method to prepare a field mapping for use in the datastore. This creates the column in the table.


getDatastoreContainer

public DatastoreContainerObject getDatastoreContainer()
Accessor for the datastore class (e.g in an RDBMS context, the Table)

Specified by:
getDatastoreContainer in class JavaTypeMapping
Returns:
The datastore class containing this mapped field.

includeInFetchStatement

public boolean includeInFetchStatement()
Accessor for the string to put in any retrieval datastore statement for this field. In RDBMS, this is typically a ? to be used in JDBC statements.

Specified by:
includeInFetchStatement in class JavaTypeMapping
Returns:
The input parameter

includeInUpdateStatement

public boolean includeInUpdateStatement()
This mapping is included in the update statement.

Specified by:
includeInUpdateStatement in class JavaTypeMapping
Returns:
Whether to include in update statement

includeInInsertStatement

public boolean includeInInsertStatement()
This mapping is included in the insert statement.

Specified by:
includeInInsertStatement in class JavaTypeMapping
Returns:
Whether to include in insert statement

equals

public boolean equals(java.lang.Object obj)
Equality operator

Parameters:
obj - The object to compare with
Returns:
Whether the objects are equal

setBoolean

public void setBoolean(PersistenceManager pm,
                       java.lang.Object preparedStatement,
                       int[] exprIndex,
                       boolean value)
Description copied from class: JavaTypeMapping
Sets a value into preparedStatement at position specified by exprIndex.

Overrides:
setBoolean in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getBoolean

public boolean getBoolean(PersistenceManager pm,
                          java.lang.Object resultSet,
                          int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from resultSet at position specified by exprIndex.

Overrides:
getBoolean in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value

setChar

public void setChar(PersistenceManager pm,
                    java.lang.Object preparedStatement,
                    int[] exprIndex,
                    char value)
Description copied from class: JavaTypeMapping
Sets a value into preparedStatement at position specified by exprIndex.

Overrides:
setChar in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getChar

public char getChar(PersistenceManager pm,
                    java.lang.Object resultSet,
                    int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from resultSet at position specified by exprIndex.

Overrides:
getChar in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value

setByte

public void setByte(PersistenceManager pm,
                    java.lang.Object preparedStatement,
                    int[] exprIndex,
                    byte value)
Description copied from class: JavaTypeMapping
Sets a value into preparedStatement at position specified by exprIndex.

Overrides:
setByte in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getByte

public byte getByte(PersistenceManager pm,
                    java.lang.Object resultSet,
                    int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from resultSet at position specified by exprIndex.

Overrides:
getByte in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value

setShort

public void setShort(PersistenceManager pm,
                     java.lang.Object preparedStatement,
                     int[] exprIndex,
                     short value)
Description copied from class: JavaTypeMapping
Sets a value into preparedStatement at position specified by exprIndex.

Overrides:
setShort in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getShort

public short getShort(PersistenceManager pm,
                      java.lang.Object resultSet,
                      int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from resultSet at position specified by exprIndex.

Overrides:
getShort in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value

setInt

public void setInt(PersistenceManager pm,
                   java.lang.Object preparedStatement,
                   int[] exprIndex,
                   int value)
Description copied from class: JavaTypeMapping
Sets a value into preparedStatement at position specified by exprIndex.

Overrides:
setInt in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getInt

public int getInt(PersistenceManager pm,
                  java.lang.Object resultSet,
                  int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from resultSet at position specified by exprIndex.

Overrides:
getInt in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value

setLong

public void setLong(PersistenceManager pm,
                    java.lang.Object preparedStatement,
                    int[] exprIndex,
                    long value)
Description copied from class: JavaTypeMapping
Sets a value into preparedStatement at position specified by exprIndex.

Overrides:
setLong in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getLong

public long getLong(PersistenceManager pm,
                    java.lang.Object resultSet,
                    int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from resultSet at position specified by exprIndex.

Overrides:
getLong in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value

setFloat

public void setFloat(PersistenceManager pm,
                     java.lang.Object preparedStatement,
                     int[] exprIndex,
                     float value)
Description copied from class: JavaTypeMapping
Sets a value into preparedStatement at position specified by exprIndex.

Overrides:
setFloat in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getFloat

public float getFloat(PersistenceManager pm,
                      java.lang.Object resultSet,
                      int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from resultSet at position specified by exprIndex.

Overrides:
getFloat in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value

setDouble

public void setDouble(PersistenceManager pm,
                      java.lang.Object preparedStatement,
                      int[] exprIndex,
                      double value)
Description copied from class: JavaTypeMapping
Sets a value into preparedStatement at position specified by exprIndex.

Overrides:
setDouble in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getDouble

public double getDouble(PersistenceManager pm,
                        java.lang.Object resultSet,
                        int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from resultSet at position specified by exprIndex.

Overrides:
getDouble in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value

setString

public void setString(PersistenceManager pm,
                      java.lang.Object preparedStatement,
                      int[] exprIndex,
                      java.lang.String value)
Description copied from class: JavaTypeMapping
Sets a value into preparedStatement at position specified by exprIndex.

Overrides:
setString in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getString

public java.lang.String getString(PersistenceManager pm,
                                  java.lang.Object resultSet,
                                  int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from resultSet at position specified by exprIndex.

Overrides:
getString in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value

setObject

public void setObject(PersistenceManager pm,
                      java.lang.Object preparedStatement,
                      int[] exprIndex,
                      java.lang.Object value)
Description copied from class: JavaTypeMapping
Sets a value into preparedStatement at position specified by exprIndex.

Overrides:
setObject in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
preparedStatement - a datastore object that executes statements in the database
exprIndex - the position of the value in the statement
value - the value

getObject

public java.lang.Object getObject(PersistenceManager pm,
                                  java.lang.Object resultSet,
                                  int[] exprIndex)
Description copied from class: JavaTypeMapping
Obtains a value from resultSet at position specified by exprIndex.

Overrides:
getObject in class JavaTypeMapping
Parameters:
pm - the PersistenceManager
resultSet - an object returned from the datastore with values
exprIndex - the position of the value in the result
Returns:
the value


Copyright © -2007 . All Rights Reserved.