org.jpox.store.mapping
Class PersistenceCapableMapping

java.lang.Object
  extended byorg.jpox.store.mapping.JavaTypeMapping
      extended byorg.jpox.store.mapping.SingleFieldMapping
          extended byorg.jpox.store.mapping.OIDMapping
              extended byorg.jpox.store.mapping.PersistenceCapableMapping
All Implemented Interfaces:
SimpleDatastoreRepresentation

public class PersistenceCapableMapping
extends OIDMapping

Maps a java field to a PersistenceCapable class. For PersistenceCapable classes using datastore identity most of the necessary behaviour is coded in the OIDMapping super class. TODO Split this from OIDMapping since a PCMapping may represent an application identity object instead of a datastore identity object

Version:
$Revision: 1.74 $

Field Summary
 
Fields inherited from class org.jpox.store.mapping.SingleFieldMapping
datastoreContainer, typeInfo
 
Fields inherited from class org.jpox.store.mapping.JavaTypeMapping
datastoreMappings, dba, fmd, LOCALISER, referenceMapping, type
 
Constructor Summary
  PersistenceCapableMapping(DatastoreAdapter dba, AbstractPropertyMetaData fmd, DatastoreContainerObject datastoreContainer, ClassLoaderResolver clr)
          Creates a new PersistenceCapableMapping object.
  PersistenceCapableMapping(DatastoreAdapter dba, java.lang.String type)
          Constructor.
protected PersistenceCapableMapping(PersistenceCapableMapping pcMapping)
          Constructor used to generate a PCMapping representing only the identity of the object.
 
Method Summary
 void addJavaTypeMapping(JavaTypeMapping mapping)
          Add a new JavaTypeMapping
 DatastoreMapping getDataStoreMapping(int index)
          Accessor for a datastore mapping.
 JavaTypeMapping getIdMapping()
          Utility to return a PC mapping representing only the identity and not the object.
 JavaTypeMapping[] getJavaTypeMapping()
          Accessor for the Java type mappings
 int getNumberOfDatastoreFields()
          Accessor for the number of datastore fields.
 java.lang.Object getObject(PersistenceManager pm, java.lang.Object rs, int[] param)
          Returns a instance of a PersistenceCapable class.
 ScalarExpression newLiteral(QueryExpression qs, java.lang.Object value)
          Creates a literal from an value.
 ScalarExpression newScalarExpression(QueryExpression qs, LogicSetExpression te)
          Creates a expression from a field name/table.
protected  void prepareDatastoreMapping()
          Method to prepare the PC mapping and add its associated datastore mappings.
protected  void prepareDatastoreMapping(ClassLoaderResolver clr)
          Method to prepare the PC mapping and add its associated datastore mappings.
 void setObject(PersistenceManager pm, java.lang.Object ps, int[] param, java.lang.Object value)
          Method to set an object in the datastore.
 void setObject(PersistenceManager pm, java.lang.Object ps, int[] param, java.lang.Object value, StateManager ownerSM, int ownerFieldNumber)
          Method to set an object in the datastore.
 
Methods inherited from class org.jpox.store.mapping.OIDMapping
getJavaType, getSampleValue
 
Methods inherited from class org.jpox.store.mapping.SingleFieldMapping
equals, getBoolean, getByte, getChar, getDatastoreContainer, getDouble, getFloat, getInt, getLong, getShort, getString, hasValue, includeInFetchStatement, includeInInsertStatement, includeInUpdateStatement, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setShort, setString
 
Methods inherited from class org.jpox.store.mapping.JavaTypeMapping
addDataStoreMapping, failureMessage, getDataStoreMappings, getFieldMetaData, getObject, getReferenceMapping, getType, isNullable, setDefault, setReferenceMapping
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistenceCapableMapping

public PersistenceCapableMapping(DatastoreAdapter dba,
                                 java.lang.String type)
Constructor.

Parameters:
dba - Datastore Adapter
type - The type of PersistenceCapable

PersistenceCapableMapping

public PersistenceCapableMapping(DatastoreAdapter dba,
                                 AbstractPropertyMetaData fmd,
                                 DatastoreContainerObject datastoreContainer,
                                 ClassLoaderResolver clr)
Creates a new PersistenceCapableMapping object.

Parameters:
dba - Database Adapter
fmd - AbstractPropertyMetaData for the field
datastoreContainer - Table for persisting this field
clr - The ClassLoaderResolver

PersistenceCapableMapping

protected PersistenceCapableMapping(PersistenceCapableMapping pcMapping)
Constructor used to generate a PCMapping representing only the identity of the object. This is typically used where the user has selected the id in a JDOQL query as a result field.

Parameters:
pcMapping - The mapping to base it on
Method Detail

getIdMapping

public JavaTypeMapping getIdMapping()
Utility to return a PC mapping representing only the identity and not the object.

Returns:
The id mapping

addJavaTypeMapping

public void addJavaTypeMapping(JavaTypeMapping mapping)
Add a new JavaTypeMapping

Parameters:
mapping - the JavaTypeMapping

prepareDatastoreMapping

protected void prepareDatastoreMapping()
Method to prepare the PC mapping and add its associated datastore mappings.

Overrides:
prepareDatastoreMapping in class SingleFieldMapping

prepareDatastoreMapping

protected void prepareDatastoreMapping(ClassLoaderResolver clr)
Method to prepare the PC mapping and add its associated datastore mappings.

Parameters:
clr - The ClassLoaderResolver

getJavaTypeMapping

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

Returns:
The Java type mappings

getNumberOfDatastoreFields

public int getNumberOfDatastoreFields()
Accessor for the number of datastore fields. Zero datastore fields implies that the mapping uses a FK in the associated class to reference back.

Overrides:
getNumberOfDatastoreFields in class JavaTypeMapping
Returns:
Number of datastore fields for this PC mapping.

getDataStoreMapping

public DatastoreMapping getDataStoreMapping(int index)
Accessor for a datastore mapping. This method works through the java type mappings, and for each mapping through its datastore mappings incrementing the index with each datastore mapping.

Overrides:
getDataStoreMapping in class JavaTypeMapping
Parameters:
index - The position of the mapping.
Returns:
The datastore mapping.

setObject

public void setObject(PersistenceManager pm,
                      java.lang.Object ps,
                      int[] param,
                      java.lang.Object value)
Method to set an object in the datastore.

Overrides:
setObject in class OIDMapping
Parameters:
pm - The Persistence Manager
ps - The Prepared Statement
param - The parameter ids in the statement
value - The value to put in the statement at these ids
Throws:
NotYetFlushedException

setObject

public void setObject(PersistenceManager pm,
                      java.lang.Object ps,
                      int[] param,
                      java.lang.Object value,
                      StateManager ownerSM,
                      int ownerFieldNumber)
Method to set an object in the datastore.

Overrides:
setObject in class JavaTypeMapping
Parameters:
pm - The Persistence Manager
ps - The Prepared Statement
param - The parameter ids in the statement
value - The value to put in the statement at these ids
ownerSM - StateManager for the owner object
ownerFieldNumber - Field number of this PC object in the owner
Throws:
NotYetFlushedException

getObject

public java.lang.Object getObject(PersistenceManager pm,
                                  java.lang.Object rs,
                                  int[] param)
Returns a instance of a PersistenceCapable class. Processes a FK field and converts the id stored firstly into an OID/AID and then into the object that the FK id relates to.

Overrides:
getObject in class OIDMapping
Parameters:
pm - The Persistence Manager
rs - The ResultSet
param - Array of parameter ids in the ResultSet to retrieve
Returns:
The Persistence Capable object

newLiteral

public ScalarExpression newLiteral(QueryExpression qs,
                                   java.lang.Object value)
Description copied from class: JavaTypeMapping
Creates a literal from an value. A string literal is enclosed in single quotes. for example: "literal". A string literal that includes a single quote is represented by two single quotes. for example: "literal''s". An exact numeric literal is a numeric value without a decimal point, such as 57, -957, +62. An approximate numeric literal is a numeric value in scientific notation, such as 7E3, -57.9E2, or a numeric value with a decimal, such as 7., -95.7, +6.2.

Overrides:
newLiteral in class OIDMapping

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

Overrides:
newScalarExpression in class OIDMapping


Copyright © -2007 . All Rights Reserved.