org.datanucleus.store.mapped.mapping
Class EmbeddedMapping

java.lang.Object
  extended by org.datanucleus.store.mapped.mapping.JavaTypeMapping
      extended by org.datanucleus.store.mapped.mapping.SingleFieldMapping
          extended by org.datanucleus.store.mapped.mapping.EmbeddedMapping
Direct Known Subclasses:
EmbeddedElementPCMapping, EmbeddedKeyPCMapping, EmbeddedPCMapping, EmbeddedValuePCMapping

public abstract class EmbeddedMapping
extends SingleFieldMapping

Mapping for an embedded PC object. The PC object can be embedded directly (1-1 relation) or be the element of a collection, or be the key or value of a map.


Field Summary
protected  ClassLoaderResolver clr
          ClassLoader resolver
protected  AbstractClassMetaData embCmd
          MetaData for the embedded class.
protected  EmbeddedMetaData emd
          EmbeddedMetaData for the object being embedded.
protected  java.util.List javaTypeMappings
          Mappings of the fields of the embedded PC.
protected  short objectType
          Type of PC object.
protected  java.lang.String typeName
          Type name for the object being embedded.
 
Fields inherited from class org.datanucleus.store.mapped.mapping.JavaTypeMapping
datastoreContainer, datastoreMappings, LOCALISER, mmd, referenceMapping, roleForMember, storeMgr, type
 
Constructor Summary
EmbeddedMapping()
           
 
Method Summary
 void addJavaTypeMapping(JavaTypeMapping mapping)
          Add a new JavaTypeMapping to manage.
 java.lang.Class getJavaType()
          Accessor for the Java type being represented here.
 JavaTypeMapping getJavaTypeMapping(int i)
          Accessor for the java type mappings
 JavaTypeMapping getJavaTypeMapping(java.lang.String fieldName)
          Accessor for the sub type mapping for a particular field name
 int getNumberOfJavaTypeMappings()
          Accessor for the number of java type mappings
 java.lang.Object getObject(ExecutionContext ec, java.lang.Object rs, int[] param)
          Accessor for the embedded object from the result set
 java.lang.Object getObject(ExecutionContext ec, java.lang.Object rs, int[] param, ObjectProvider ownerSM, int ownerFieldNumber)
          Accessor for the embedded object from the result set
 void initialize(AbstractMemberMetaData fmd, DatastoreContainerObject container, ClassLoaderResolver clr)
          Initialize this JavaTypeMapping with the given DatastoreAdapter for the given FieldMetaData.
 void initialize(AbstractMemberMetaData fmd, DatastoreContainerObject datastoreContainer, ClassLoaderResolver clr, EmbeddedMetaData emd, java.lang.String typeName, int objectType)
          Initialize this JavaTypeMapping with the given DatastoreAdapter for the given MetaData.
protected  void prepareDatastoreMapping()
          Method to prepare a field mapping for use in the datastore.
 void setObject(ExecutionContext ec, java.lang.Object ps, int[] param, java.lang.Object value)
          Mutator for the embedded object in the datastore.
 void setObject(ExecutionContext ec, java.lang.Object ps, int[] param, java.lang.Object value, ObjectProvider ownerSM, int ownerFieldNumber)
          Mutator for the embedded object in the datastore.
 
Methods inherited from class org.datanucleus.store.mapped.mapping.SingleFieldMapping
equals, getBoolean, getByte, getChar, getDefaultLength, getDouble, getFloat, getInt, getJavaTypeForDatastoreMapping, getLong, getShort, getString, getValidValues, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setShort, setString
 
Methods inherited from class org.datanucleus.store.mapped.mapping.JavaTypeMapping
addDatastoreMapping, failureMessage, getColumnMetaDataForMember, getDatastoreContainer, getDatastoreMapping, getDatastoreMappings, getMemberMetaData, getNumberOfDatastoreMappings, getReferenceMapping, getRoleForMember, getType, getValueForDatastoreMapping, hashCode, hasSimpleDatastoreRepresentation, includeInFetchStatement, includeInInsertStatement, includeInUpdateStatement, initialize, isNullable, isSerialised, setDatastoreContainer, setMemberMetaData, setReferenceMapping, setRoleForMember
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

javaTypeMappings

protected java.util.List javaTypeMappings
Mappings of the fields of the embedded PC.


clr

protected ClassLoaderResolver clr
ClassLoader resolver


emd

protected EmbeddedMetaData emd
EmbeddedMetaData for the object being embedded.


typeName

protected java.lang.String typeName
Type name for the object being embedded.


objectType

protected short objectType
Type of PC object. Corresponds to the values in StateManagerImpl.


embCmd

protected AbstractClassMetaData embCmd
MetaData for the embedded class.

Constructor Detail

EmbeddedMapping

public EmbeddedMapping()
Method Detail

initialize

public void initialize(AbstractMemberMetaData fmd,
                       DatastoreContainerObject container,
                       ClassLoaderResolver clr)
Initialize this JavaTypeMapping with the given DatastoreAdapter for the given FieldMetaData.

Overrides:
initialize in class SingleFieldMapping
Parameters:
container - The datastore container storing this mapping (if any)
clr - the ClassLoaderResolver
fmd - FieldMetaData for the field to be mapped (if any)
Throws:
NucleusException

initialize

public void initialize(AbstractMemberMetaData fmd,
                       DatastoreContainerObject datastoreContainer,
                       ClassLoaderResolver clr,
                       EmbeddedMetaData emd,
                       java.lang.String typeName,
                       int objectType)
Initialize this JavaTypeMapping with the given DatastoreAdapter for the given MetaData.

Parameters:
fmd - metadata for the field
datastoreContainer - Table for persisting this field
clr - The ClassLoaderResolver
emd - Embedded MetaData for the object being embedded
typeName - type of the embedded PC object
objectType - Type of the PC object being embedded (see StateManagerImpl object types)

prepareDatastoreMapping

protected void prepareDatastoreMapping()
Method to prepare a field mapping for use in the datastore. Overridden so it does nothing

Overrides:
prepareDatastoreMapping in class SingleFieldMapping

addJavaTypeMapping

public void addJavaTypeMapping(JavaTypeMapping mapping)
Add a new JavaTypeMapping to manage.

Parameters:
mapping - the JavaTypeMapping

getNumberOfJavaTypeMappings

public int getNumberOfJavaTypeMappings()
Accessor for the number of java type mappings

Returns:
Number of java type mappings of the fields of the embedded PC element

getJavaTypeMapping

public JavaTypeMapping getJavaTypeMapping(int i)
Accessor for the java type mappings

Parameters:
i - the index position of the java type mapping
Returns:
the java type mapping

getJavaTypeMapping

public JavaTypeMapping getJavaTypeMapping(java.lang.String fieldName)
Accessor for the sub type mapping for a particular field name

Parameters:
fieldName - The field name
Returns:
The type mapping for that field in the embedded object

setObject

public void setObject(ExecutionContext ec,
                      java.lang.Object ps,
                      int[] param,
                      java.lang.Object value)
Mutator for the embedded object in the datastore.

Overrides:
setObject in class SingleFieldMapping
Parameters:
ec - execution context
ps - The Prepared Statement
param - Param numbers in the PreparedStatement for the fields of this object
value - The embedded object to use

setObject

public void setObject(ExecutionContext ec,
                      java.lang.Object ps,
                      int[] param,
                      java.lang.Object value,
                      ObjectProvider ownerSM,
                      int ownerFieldNumber)
Mutator for the embedded object in the datastore.

Overrides:
setObject in class JavaTypeMapping
Parameters:
ec - ExecutionContext
ps - The Prepared Statement
param - Param numbers in the PreparedStatement for the fields of this object
value - The embedded object to use
ownerSM - StateManager of the owning object containing this embedded object
ownerFieldNumber - Field number in the owning object where this is stored

getObject

public java.lang.Object getObject(ExecutionContext ec,
                                  java.lang.Object rs,
                                  int[] param)
Accessor for the embedded object from the result set

Overrides:
getObject in class SingleFieldMapping
Parameters:
ec - ExecutionContext
rs - The ResultSet
param - Array of param numbers in the ResultSet for the fields of this object
Returns:
The embedded object

getObject

public java.lang.Object getObject(ExecutionContext ec,
                                  java.lang.Object rs,
                                  int[] param,
                                  ObjectProvider ownerSM,
                                  int ownerFieldNumber)
Accessor for the embedded object from the result set

Overrides:
getObject in class JavaTypeMapping
Parameters:
ec - ExecutionContext
rs - The ResultSet
param - Array of param numbers in the ResultSet for the fields of this object
ownerSM - StateManager of the owning object containing this embedded object
ownerFieldNumber - Field number in the owning object where this is stored
Returns:
The embedded object

getJavaType

public java.lang.Class getJavaType()
Accessor for the Java type being represented here.

Specified by:
getJavaType in class JavaTypeMapping
Returns:
The Java type


Copyright © 2011. All Rights Reserved.