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  int 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(ObjectManager om, java.lang.Object rs, int[] param)
          Accessor for the embedded object from the result set
 java.lang.Object getObject(ObjectManager om, java.lang.Object rs, int[] param, StateManager ownerSM, int ownerFieldNumber)
          Accessor for the embedded object from the result set
 java.lang.Object getSampleValue(ClassLoaderResolver clr)
          Accessor for the sample value for this type.
 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.
 ScalarExpression newLiteral(QueryExpression qs, java.lang.Object value)
          Creates a literal from an value for use in TJDO-style JDOQL.
 ScalarExpression newScalarExpression(QueryExpression qs, LogicSetExpression te)
          Creates a expression from a field name/table.
protected  void prepareDatastoreMapping()
          Method to prepare a field mapping for use in the datastore.
 void setObject(ObjectManager om, java.lang.Object ps, int[] param, java.lang.Object value)
          Mutator for the embedded object in the datastore.
 void setObject(ObjectManager om, java.lang.Object ps, int[] param, java.lang.Object value, StateManager 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, setDefault, 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 int 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(ObjectManager om,
                      java.lang.Object ps,
                      int[] param,
                      java.lang.Object value)
Mutator for the embedded object in the datastore.

Overrides:
setObject in class SingleFieldMapping
Parameters:
om - The Object Manager managing this object
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(ObjectManager om,
                      java.lang.Object ps,
                      int[] param,
                      java.lang.Object value,
                      StateManager ownerSM,
                      int ownerFieldNumber)
Mutator for the embedded object in the datastore.

Overrides:
setObject in class JavaTypeMapping
Parameters:
om - The Object Manager managing this object
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(ObjectManager om,
                                  java.lang.Object rs,
                                  int[] param)
Accessor for the embedded object from the result set

Overrides:
getObject in class SingleFieldMapping
Parameters:
om - ObjectManager managing this object
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(ObjectManager om,
                                  java.lang.Object rs,
                                  int[] param,
                                  StateManager ownerSM,
                                  int ownerFieldNumber)
Accessor for the embedded object from the result set

Overrides:
getObject in class JavaTypeMapping
Parameters:
om - Object Manager managing this object
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

getSampleValue

public java.lang.Object getSampleValue(ClassLoaderResolver clr)
Accessor for the sample value for this type.

Overrides:
getSampleValue in class JavaTypeMapping
Parameters:
clr - ClassLoader resolver
Returns:
Sample value

getJavaType

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

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

newLiteral

public ScalarExpression newLiteral(QueryExpression qs,
                                   java.lang.Object value)
Description copied from class: JavaTypeMapping
Creates a literal from an value for use in TJDO-style JDOQL. This implementation just throws a NucleusException.

Overrides:
newLiteral in class JavaTypeMapping
Parameters:
qs - The Query statement
value - The object
Returns:
A Scalar Expression TODO Remove this when we drop legacy query mechanism

newScalarExpression

public ScalarExpression newScalarExpression(QueryExpression qs,
                                            LogicSetExpression te)
Description copied from class: JavaTypeMapping
Creates a expression from a field name/table. e.g. tablename.fieldname; tablealias.fieldalias For use in TJDO-style JDOQL. This implementation just throws a NucleusException.

Overrides:
newScalarExpression in class JavaTypeMapping
Parameters:
qs - The Query statement
te - the alias for the table
Returns:
A Scalar Expression TODO Remove this when we drop legacy query mechanism


Copyright © 2010. All Rights Reserved.