org.jpox.store.rdbms.mapping
Class RDBMSMapping

java.lang.Object
  extended byorg.jpox.store.rdbms.mapping.RDBMSMapping
All Implemented Interfaces:
DatastoreMapping
Direct Known Subclasses:
ColumnMapping

public abstract class RDBMSMapping
extends java.lang.Object
implements DatastoreMapping

Implementation of the mapping of an RDBMS type.

Version:
$Revision: 1.10 $

Field Summary
protected static Localiser LOCALISER
           
protected static Localiser LOCALISER_STORE
           
protected  JavaTypeMapping mapping
          Mapping of the Java type.
protected  StoreManager storeMgr
          Store Manager to use for mapping.
 
Constructor Summary
protected RDBMSMapping(StoreManager storeMgr, JavaTypeMapping mapping)
          Create a new Mapping with the given DatabaseAdapter for the given type.
 
Method Summary
protected  java.lang.String failureMessage(java.lang.String method)
          Utility to output any error message.
 boolean getBoolean(java.lang.Object resultSet, int exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
 byte getByte(java.lang.Object resultSet, int exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
 char getChar(java.lang.Object resultSet, int exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
protected  RDBMSAdapter getDatabaseAdapter()
          Convenience to access the Datastore adapter as a DatabaseAdapter.
 double getDouble(java.lang.Object resultSet, int exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
 float getFloat(java.lang.Object resultSet, int exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
abstract  java.lang.String getInsertionInputParameter()
          Accessor for the string to put in any retrieval datastore statement for this field.
 int getInt(java.lang.Object resultSet, int exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
 JavaTypeMapping getJavaTypeMapping()
          Accessor for the java type mapping
 long getLong(java.lang.Object resultSet, int exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
 java.lang.Object getObject(java.lang.Object resultSet, int exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
 short getShort(java.lang.Object resultSet, int exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
 java.lang.String getString(java.lang.Object resultSet, int exprIndex)
          Obtains a value from resultSet at position specified by exprIndex.
abstract  TypeInfo getTypeInfo()
          Accessor for the type info for this datastore type.
abstract  java.lang.String getUpdateInputParameter()
          Accessor for the string to put in any update datastore statements for this field.
abstract  boolean includeInFetchStatement()
          Whether this mapping is included in the fetch statement.
abstract  boolean isNullable()
          Accessor for whether the mapping is nullable.
 void setBoolean(java.lang.Object preparedStatement, int exprIndex, boolean value)
          Sets a value into preparedStatement at position specified by paramIndex.
 void setByte(java.lang.Object preparedStatement, int exprIndex, byte value)
          Sets a value into preparedStatement at position specified by paramIndex.
 void setChar(java.lang.Object preparedStatement, int exprIndex, char value)
          Sets a value into preparedStatement at position specified by paramIndex.
 void setDouble(java.lang.Object preparedStatement, int exprIndex, double value)
          Sets a value into preparedStatement at position specified by paramIndex.
 void setFloat(java.lang.Object preparedStatement, int exprIndex, float value)
          Sets a value into preparedStatement at position specified by paramIndex.
 void setInt(java.lang.Object preparedStatement, int exprIndex, int value)
          Sets a value into preparedStatement at position specified by paramIndex.
 void setLong(java.lang.Object preparedStatement, int exprIndex, long value)
          Sets a value into preparedStatement at position specified by paramIndex.
 void setObject(java.lang.Object preparedStatement, int exprIndex, java.lang.Object value)
          Sets a value into preparedStatement at position specified by paramIndex.
 void setShort(java.lang.Object preparedStatement, int exprIndex, short value)
          Sets a value into preparedStatement at position specified by paramIndex.
 void setString(java.lang.Object preparedStatement, int exprIndex, java.lang.String value)
          Sets a value into preparedStatement at position specified by paramIndex.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jpox.store.mapping.DatastoreMapping
getDatastoreField
 

Field Detail

LOCALISER_STORE

protected static final Localiser LOCALISER_STORE

LOCALISER

protected static final Localiser LOCALISER

storeMgr

protected final StoreManager storeMgr
Store Manager to use for mapping.


mapping

protected final JavaTypeMapping mapping
Mapping of the Java type.

Constructor Detail

RDBMSMapping

protected RDBMSMapping(StoreManager storeMgr,
                       JavaTypeMapping mapping)
Create a new Mapping with the given DatabaseAdapter for the given type.

Parameters:
storeMgr - The Store Manager that this Mapping should use.
mapping - The Class that this mapping maps to the database.
Method Detail

getDatabaseAdapter

protected RDBMSAdapter getDatabaseAdapter()
Convenience to access the Datastore adapter as a DatabaseAdapter.

Returns:
The adapter in use

getJavaTypeMapping

public JavaTypeMapping getJavaTypeMapping()
Accessor for the java type mapping

Specified by:
getJavaTypeMapping in interface DatastoreMapping
Returns:
The java type mapping used

getTypeInfo

public abstract TypeInfo getTypeInfo()
Accessor for the type info for this datastore type. TODO Move this to DatastoreMapping when we have a generic "TypeInfo" that could apply to other datastores.

Returns:
The type info

isNullable

public abstract boolean isNullable()
Accessor for whether the mapping is nullable.

Specified by:
isNullable in interface DatastoreMapping
Returns:
Whether it is nullable

includeInFetchStatement

public abstract boolean includeInFetchStatement()
Whether this mapping is included in the fetch statement.

Returns:
Whether to include in fetch statement

getInsertionInputParameter

public abstract java.lang.String getInsertionInputParameter()
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.

Returns:
The input parameter

getUpdateInputParameter

public abstract java.lang.String getUpdateInputParameter()
Accessor for the string to put in any update datastore statements for this field. In RDBMS, this is typically a ? to be used in JDBC statements.

Returns:
The input parameter.

failureMessage

protected java.lang.String failureMessage(java.lang.String method)
Utility to output any error message.

Parameters:
method - The method that failed.
Returns:
The localised failure message

setBoolean

public void setBoolean(java.lang.Object preparedStatement,
                       int exprIndex,
                       boolean value)
Description copied from interface: DatastoreMapping
Sets a value into preparedStatement at position specified by paramIndex.

Specified by:
setBoolean in interface DatastoreMapping
Parameters:
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(java.lang.Object resultSet,
                          int exprIndex)
Description copied from interface: DatastoreMapping
Obtains a value from resultSet at position specified by exprIndex.

Specified by:
getBoolean in interface DatastoreMapping
Parameters:
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(java.lang.Object preparedStatement,
                    int exprIndex,
                    char value)
Description copied from interface: DatastoreMapping
Sets a value into preparedStatement at position specified by paramIndex.

Specified by:
setChar in interface DatastoreMapping
Parameters:
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(java.lang.Object resultSet,
                    int exprIndex)
Description copied from interface: DatastoreMapping
Obtains a value from resultSet at position specified by exprIndex.

Specified by:
getChar in interface DatastoreMapping
Parameters:
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(java.lang.Object preparedStatement,
                    int exprIndex,
                    byte value)
Description copied from interface: DatastoreMapping
Sets a value into preparedStatement at position specified by paramIndex.

Specified by:
setByte in interface DatastoreMapping
Parameters:
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(java.lang.Object resultSet,
                    int exprIndex)
Description copied from interface: DatastoreMapping
Obtains a value from resultSet at position specified by exprIndex.

Specified by:
getByte in interface DatastoreMapping
Parameters:
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(java.lang.Object preparedStatement,
                     int exprIndex,
                     short value)
Description copied from interface: DatastoreMapping
Sets a value into preparedStatement at position specified by paramIndex.

Specified by:
setShort in interface DatastoreMapping
Parameters:
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(java.lang.Object resultSet,
                      int exprIndex)
Description copied from interface: DatastoreMapping
Obtains a value from resultSet at position specified by exprIndex.

Specified by:
getShort in interface DatastoreMapping
Parameters:
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(java.lang.Object preparedStatement,
                   int exprIndex,
                   int value)
Description copied from interface: DatastoreMapping
Sets a value into preparedStatement at position specified by paramIndex.

Specified by:
setInt in interface DatastoreMapping
Parameters:
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(java.lang.Object resultSet,
                  int exprIndex)
Description copied from interface: DatastoreMapping
Obtains a value from resultSet at position specified by exprIndex.

Specified by:
getInt in interface DatastoreMapping
Parameters:
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(java.lang.Object preparedStatement,
                    int exprIndex,
                    long value)
Description copied from interface: DatastoreMapping
Sets a value into preparedStatement at position specified by paramIndex.

Specified by:
setLong in interface DatastoreMapping
Parameters:
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(java.lang.Object resultSet,
                    int exprIndex)
Description copied from interface: DatastoreMapping
Obtains a value from resultSet at position specified by exprIndex.

Specified by:
getLong in interface DatastoreMapping
Parameters:
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(java.lang.Object preparedStatement,
                     int exprIndex,
                     float value)
Description copied from interface: DatastoreMapping
Sets a value into preparedStatement at position specified by paramIndex.

Specified by:
setFloat in interface DatastoreMapping
Parameters:
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(java.lang.Object resultSet,
                      int exprIndex)
Description copied from interface: DatastoreMapping
Obtains a value from resultSet at position specified by exprIndex.

Specified by:
getFloat in interface DatastoreMapping
Parameters:
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(java.lang.Object preparedStatement,
                      int exprIndex,
                      double value)
Description copied from interface: DatastoreMapping
Sets a value into preparedStatement at position specified by paramIndex.

Specified by:
setDouble in interface DatastoreMapping
Parameters:
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(java.lang.Object resultSet,
                        int exprIndex)
Description copied from interface: DatastoreMapping
Obtains a value from resultSet at position specified by exprIndex.

Specified by:
getDouble in interface DatastoreMapping
Parameters:
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(java.lang.Object preparedStatement,
                      int exprIndex,
                      java.lang.String value)
Description copied from interface: DatastoreMapping
Sets a value into preparedStatement at position specified by paramIndex.

Specified by:
setString in interface DatastoreMapping
Parameters:
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(java.lang.Object resultSet,
                                  int exprIndex)
Description copied from interface: DatastoreMapping
Obtains a value from resultSet at position specified by exprIndex.

Specified by:
getString in interface DatastoreMapping
Parameters:
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(java.lang.Object preparedStatement,
                      int exprIndex,
                      java.lang.Object value)
Description copied from interface: DatastoreMapping
Sets a value into preparedStatement at position specified by paramIndex.

Specified by:
setObject in interface DatastoreMapping
Parameters:
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(java.lang.Object resultSet,
                                  int exprIndex)
Description copied from interface: DatastoreMapping
Obtains a value from resultSet at position specified by exprIndex.

Specified by:
getObject in interface DatastoreMapping
Parameters:
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.