org.datanucleus.store.rdbms.mapping
Class RDBMSMapping

java.lang.Object
  extended by org.datanucleus.store.rdbms.mapping.RDBMSMapping
All Implemented Interfaces:
org.datanucleus.store.mapped.mapping.DatastoreMapping
Direct Known Subclasses:
AbstractLargeBinaryRDBMSMapping, BigIntRDBMSMapping, BooleanRDBMSMapping, CharRDBMSMapping, DateRDBMSMapping, DecimalRDBMSMapping, DoubleRDBMSMapping, IntegerRDBMSMapping, LongVarcharRDBMSMapping, NumericRDBMSMapping, OracleBlobRDBMSMapping, RealRDBMSMapping, SmallIntRDBMSMapping, TimeRDBMSMapping, TimestampRDBMSMapping, TinyIntRDBMSMapping

public abstract class RDBMSMapping
extends java.lang.Object
implements org.datanucleus.store.mapped.mapping.DatastoreMapping

Implementation of the mapping of an RDBMS type.


Field Summary
protected  Column column
          The RDBMS Column being persisted to.
protected static org.datanucleus.util.Localiser LOCALISER
           
protected static org.datanucleus.util.Localiser LOCALISER_STORE
           
protected  org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping
          Mapping of the Java type.
protected  org.datanucleus.store.mapped.MappedStoreManager storeMgr
          Store Manager to use for mapping.
 
Constructor Summary
protected RDBMSMapping(org.datanucleus.store.mapped.MappedStoreManager storeMgr, org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping)
          Create a new Mapping with the given DatabaseAdapter for the given type.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
protected  java.lang.String failureMessage(java.lang.String method)
          Utility to output any error message.
 boolean getBoolean(java.lang.Object resultSet, int exprIndex)
           
 byte getByte(java.lang.Object resultSet, int exprIndex)
           
 char getChar(java.lang.Object resultSet, int exprIndex)
           
 Column getColumn()
           
protected  RDBMSAdapter getDatabaseAdapter()
          Convenience to access the Datastore adapter as a DatabaseAdapter.
 org.datanucleus.store.mapped.DatastoreField getDatastoreField()
          Accessor for the datastore field
 double getDouble(java.lang.Object resultSet, int exprIndex)
           
 float getFloat(java.lang.Object resultSet, int exprIndex)
           
 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)
           
 org.datanucleus.store.mapped.mapping.JavaTypeMapping getJavaTypeMapping()
          Accessor for the java type mapping
 long getLong(java.lang.Object resultSet, int exprIndex)
           
 java.lang.Object getObject(java.lang.Object resultSet, int exprIndex)
           
 short getShort(java.lang.Object resultSet, int exprIndex)
           
 java.lang.String getString(java.lang.Object resultSet, int exprIndex)
           
abstract  SQLTypeInfo getTypeInfo()
          Accessor for the (SQL) type info for this datastore type.
 java.lang.String getUpdateInputParameter()
          Accessor for the string to put in any update datastore statements for this field.
 int hashCode()
           
 boolean includeInFetchStatement()
          Whether this mapping is included in the fetch statement.
protected  void initTypeInfo()
          Sets the TypeInfo for the columns of the Mapping.
 boolean insertValuesOnInsert()
          Accessor for whether this mapping requires values inserting on an INSERT.
 boolean isBitBased()
          Accessor for whether the mapping is bit-based.
 boolean isBooleanBased()
          Accessor for whether the mapping is boolean-based.
 boolean isDecimalBased()
          Accessor for whether the mapping is decimal-based.
 boolean isIntegerBased()
          Accessor for whether the mapping is integer-based.
 boolean isNullable()
          Accessor for whether the mapping is nullable.
 boolean isStringBased()
          Accessor for whether the mapping is string-based.
 void setBoolean(java.lang.Object preparedStatement, int exprIndex, boolean value)
           
 void setByte(java.lang.Object preparedStatement, int exprIndex, byte value)
           
 void setChar(java.lang.Object preparedStatement, int exprIndex, char value)
           
 void setDouble(java.lang.Object preparedStatement, int exprIndex, double value)
           
 void setFloat(java.lang.Object preparedStatement, int exprIndex, float value)
           
 void setInt(java.lang.Object preparedStatement, int exprIndex, int value)
           
 void setLong(java.lang.Object preparedStatement, int exprIndex, long value)
           
 void setObject(java.lang.Object preparedStatement, int exprIndex, java.lang.Object value)
           
 void setShort(java.lang.Object preparedStatement, int exprIndex, short value)
           
 void setString(java.lang.Object preparedStatement, int exprIndex, java.lang.String value)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER_STORE

protected static final org.datanucleus.util.Localiser LOCALISER_STORE

LOCALISER

protected static final org.datanucleus.util.Localiser LOCALISER

storeMgr

protected final org.datanucleus.store.mapped.MappedStoreManager storeMgr
Store Manager to use for mapping.


mapping

protected final org.datanucleus.store.mapped.mapping.JavaTypeMapping mapping
Mapping of the Java type.


column

protected Column column
The RDBMS Column being persisted to.

Constructor Detail

RDBMSMapping

protected RDBMSMapping(org.datanucleus.store.mapped.MappedStoreManager storeMgr,
                       org.datanucleus.store.mapped.mapping.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 - Mapping for the underlying java type. This can be null on an "unmapped column".
Method Detail

getDatabaseAdapter

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

Returns:
The adapter in use

getJavaTypeMapping

public org.datanucleus.store.mapped.mapping.JavaTypeMapping getJavaTypeMapping()
Accessor for the java type mapping

Specified by:
getJavaTypeMapping in interface org.datanucleus.store.mapped.mapping.DatastoreMapping
Returns:
The java type mapping used

getTypeInfo

public abstract SQLTypeInfo getTypeInfo()
Accessor for the (SQL) type info for this datastore type.

Returns:
The type info

isNullable

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

Specified by:
isNullable in interface org.datanucleus.store.mapped.mapping.DatastoreMapping
Returns:
Whether it is nullable

includeInFetchStatement

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

Returns:
Whether to include in fetch statement

insertValuesOnInsert

public boolean insertValuesOnInsert()
Accessor for whether this mapping requires values inserting on an INSERT.

Returns:
Whether values are to be inserted into this mapping on an INSERT

getInsertionInputParameter

public 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 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)
Specified by:
setBoolean in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

getBoolean

public boolean getBoolean(java.lang.Object resultSet,
                          int exprIndex)
Specified by:
getBoolean in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

setChar

public void setChar(java.lang.Object preparedStatement,
                    int exprIndex,
                    char value)
Specified by:
setChar in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

getChar

public char getChar(java.lang.Object resultSet,
                    int exprIndex)
Specified by:
getChar in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

setByte

public void setByte(java.lang.Object preparedStatement,
                    int exprIndex,
                    byte value)
Specified by:
setByte in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

getByte

public byte getByte(java.lang.Object resultSet,
                    int exprIndex)
Specified by:
getByte in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

setShort

public void setShort(java.lang.Object preparedStatement,
                     int exprIndex,
                     short value)
Specified by:
setShort in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

getShort

public short getShort(java.lang.Object resultSet,
                      int exprIndex)
Specified by:
getShort in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

setInt

public void setInt(java.lang.Object preparedStatement,
                   int exprIndex,
                   int value)
Specified by:
setInt in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

getInt

public int getInt(java.lang.Object resultSet,
                  int exprIndex)
Specified by:
getInt in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

setLong

public void setLong(java.lang.Object preparedStatement,
                    int exprIndex,
                    long value)
Specified by:
setLong in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

getLong

public long getLong(java.lang.Object resultSet,
                    int exprIndex)
Specified by:
getLong in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

setFloat

public void setFloat(java.lang.Object preparedStatement,
                     int exprIndex,
                     float value)
Specified by:
setFloat in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

getFloat

public float getFloat(java.lang.Object resultSet,
                      int exprIndex)
Specified by:
getFloat in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

setDouble

public void setDouble(java.lang.Object preparedStatement,
                      int exprIndex,
                      double value)
Specified by:
setDouble in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

getDouble

public double getDouble(java.lang.Object resultSet,
                        int exprIndex)
Specified by:
getDouble in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

setString

public void setString(java.lang.Object preparedStatement,
                      int exprIndex,
                      java.lang.String value)
Specified by:
setString in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

getString

public java.lang.String getString(java.lang.Object resultSet,
                                  int exprIndex)
Specified by:
getString in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

setObject

public void setObject(java.lang.Object preparedStatement,
                      int exprIndex,
                      java.lang.Object value)
Specified by:
setObject in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

getObject

public java.lang.Object getObject(java.lang.Object resultSet,
                                  int exprIndex)
Specified by:
getObject in interface org.datanucleus.store.mapped.mapping.DatastoreMapping

isDecimalBased

public boolean isDecimalBased()
Accessor for whether the mapping is decimal-based.

Specified by:
isDecimalBased in interface org.datanucleus.store.mapped.mapping.DatastoreMapping
Returns:
Whether the mapping is decimal based

isIntegerBased

public boolean isIntegerBased()
Accessor for whether the mapping is integer-based.

Specified by:
isIntegerBased in interface org.datanucleus.store.mapped.mapping.DatastoreMapping
Returns:
Whether the mapping is integer based

isStringBased

public boolean isStringBased()
Accessor for whether the mapping is string-based.

Specified by:
isStringBased in interface org.datanucleus.store.mapped.mapping.DatastoreMapping
Returns:
Whether the mapping is string based

isBitBased

public boolean isBitBased()
Accessor for whether the mapping is bit-based.

Specified by:
isBitBased in interface org.datanucleus.store.mapped.mapping.DatastoreMapping
Returns:
Whether the mapping is bit based

isBooleanBased

public boolean isBooleanBased()
Accessor for whether the mapping is boolean-based.

Specified by:
isBooleanBased in interface org.datanucleus.store.mapped.mapping.DatastoreMapping
Returns:
Whether the mapping is boolean based

getDatastoreField

public org.datanucleus.store.mapped.DatastoreField getDatastoreField()
Accessor for the datastore field

Specified by:
getDatastoreField in interface org.datanucleus.store.mapped.mapping.DatastoreMapping
Returns:
The column

initTypeInfo

protected void initTypeInfo()
Sets the TypeInfo for the columns of the Mapping. Mappings using two or more columns using different TypeInfo(s) should overwrite this method to appropriate set the TypeInfo (SQL type) for all the columns


getColumn

public Column getColumn()
Returns:
Returns the column.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 2009. All Rights Reserved.