org.datanucleus.store.mapped.mapping
Class MultiMapping

java.lang.Object
  extended by org.datanucleus.store.mapped.mapping.JavaTypeMapping
      extended by org.datanucleus.store.mapped.mapping.MultiMapping
Direct Known Subclasses:
ReferenceMapping, SubclassPCMapping

public abstract class MultiMapping
extends JavaTypeMapping

Mapping to represent multiple mappings within the single overall java type mapping. This mapping can be used to represent, for example,


Field Summary
protected  JavaTypeMapping[] javaTypeMappings
          The Java mappings represented by this mapping.
protected  int numberOfDatastoreMappings
          Number of datastore mappings - for convenience to improve performance
 
Fields inherited from class org.datanucleus.store.mapped.mapping.JavaTypeMapping
datastoreContainer, datastoreMappings, LOCALISER, mmd, referenceMapping, roleForMember, storeMgr, type
 
Constructor Summary
MultiMapping()
           
 
Method Summary
 void addJavaTypeMapping(JavaTypeMapping mapping)
          Method to add a Java type mapping for a field
 DatastoreMapping getDatastoreMapping(int index)
          Accessor for a datastore mapping.
 DatastoreMapping[] getDatastoreMappings()
          Accessor for the datastore mappings for this java type
 JavaTypeMapping[] getJavaTypeMapping()
          Accessor for the Java type mappings
 int getMappingNumberForValue(ExecutionContext ec, java.lang.Object value)
          Convenience accessor for the number of the java type mapping where the passed value would be stored.
 int getNumberOfDatastoreMappings()
          Accessor for the number of datastore mappings.
 java.lang.Object getObject(ExecutionContext ec, java.lang.Object rs, int[] pos)
          Method to retrieve an object of this type from the ResultSet.
 void setObject(ExecutionContext ec, java.lang.Object ps, int[] pos, java.lang.Object value)
          Method to set the parameters in the PreparedStatement with the fields of this object.
 void setObject(ExecutionContext ec, java.lang.Object ps, int[] pos, java.lang.Object value, ObjectProvider ownerSM, int ownerFieldNumber)
          Sets the specified positions in the PreparedStatement associated with this field, and value.
 
Methods inherited from class org.datanucleus.store.mapped.mapping.JavaTypeMapping
addDatastoreMapping, equals, failureMessage, getBoolean, getByte, getChar, getColumnMetaDataForMember, getDatastoreContainer, getDouble, getFloat, getInt, getJavaType, getJavaTypeForDatastoreMapping, getLong, getMemberMetaData, getObject, getReferenceMapping, getRoleForMember, getShort, getString, getType, getValueForDatastoreMapping, hashCode, hasSimpleDatastoreRepresentation, includeInFetchStatement, includeInInsertStatement, includeInUpdateStatement, initialize, initialize, isNullable, isSerialised, setBoolean, setByte, setChar, setDatastoreContainer, setDouble, setFloat, setInt, setLong, setMemberMetaData, setReferenceMapping, setRoleForMember, setShort, setString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

javaTypeMappings

protected JavaTypeMapping[] javaTypeMappings
The Java mappings represented by this mapping.


numberOfDatastoreMappings

protected int numberOfDatastoreMappings
Number of datastore mappings - for convenience to improve performance

Constructor Detail

MultiMapping

public MultiMapping()
Method Detail

addJavaTypeMapping

public void addJavaTypeMapping(JavaTypeMapping mapping)
Method to add a Java type mapping for a field

Parameters:
mapping - The mapping to add

getJavaTypeMapping

public JavaTypeMapping[] getJavaTypeMapping()
Accessor for the Java type mappings

Returns:
The Java type mappings

getNumberOfDatastoreMappings

public int getNumberOfDatastoreMappings()
Accessor for the number of datastore mappings.

Overrides:
getNumberOfDatastoreMappings in class JavaTypeMapping
Returns:
The number of datastore mappings.

getDatastoreMappings

public DatastoreMapping[] getDatastoreMappings()
Description copied from class: JavaTypeMapping
Accessor for the datastore mappings for this java type

Overrides:
getDatastoreMappings in class JavaTypeMapping
Returns:
The datastore mapping(s)

getDatastoreMapping

public DatastoreMapping getDatastoreMapping(int index)
Accessor for a datastore mapping.

Overrides:
getDatastoreMapping in class JavaTypeMapping
Parameters:
index - The position of the mapping to return
Returns:
The datastore mapping

getMappingNumberForValue

public int getMappingNumberForValue(ExecutionContext ec,
                                    java.lang.Object value)
Convenience accessor for the number of the java type mapping where the passed value would be stored. If no suitable mapping is found will return -1. If is a persistent interface then will return -2 meaning persist against *any* mapping

Parameters:
ec - ExecutionContext
value - The value
Returns:
The index of javaTypeMappings to use (if any), or -1 (none), or -2 (any)

setObject

public void setObject(ExecutionContext ec,
                      java.lang.Object ps,
                      int[] pos,
                      java.lang.Object value)
Method to set the parameters in the PreparedStatement with the fields of this object.

Overrides:
setObject in class JavaTypeMapping
Parameters:
ec - execution context
ps - The PreparedStatement
pos - The parameter positions
value - The object to populate the statement with
Throws:
NotYetFlushedException - Thrown if the object is not yet flushed to the datastore

setObject

public void setObject(ExecutionContext ec,
                      java.lang.Object ps,
                      int[] pos,
                      java.lang.Object value,
                      ObjectProvider ownerSM,
                      int ownerFieldNumber)
Sets the specified positions in the PreparedStatement associated with this field, and value.

Overrides:
setObject in class JavaTypeMapping
Parameters:
ec - execution context
ps - a datastore object that executes statements in the database
pos - The position(s) of the PreparedStatement to populate
value - the value stored in this field
ownerSM - the owner StateManager
ownerFieldNumber - the owner absolute field number

getObject

public java.lang.Object getObject(ExecutionContext ec,
                                  java.lang.Object rs,
                                  int[] pos)
Method to retrieve an object of this type from the ResultSet.

Overrides:
getObject in class JavaTypeMapping
Parameters:
ec - execution context
rs - The ResultSet
pos - The parameter positions
Returns:
The object


Copyright © 2011. All Rights Reserved.