org.jpox.store.rdbms.scostore
Class FKMapStore

java.lang.Object
  extended by org.jpox.store.rdbms.scostore.FKMapStore
All Implemented Interfaces:
org.jpox.store.mapped.scostore.MapStoreQueryable, org.jpox.store.scostore.MapStore, org.jpox.store.scostore.Store

public class FKMapStore
extends java.lang.Object

Representation of a FK backing for a Map. This class is used where you have a 1-N and the tables are not joined via a link table, instead using a FK. There are 2 possible uses here

In both cases the value class will have a field that represents the key, and so the user must specify a 'key mapped-by="..."' attribute to denote which field is the key, or a 'value mapped-by="..."' to denote which field is the value.

Version:
$Revision: 1.43 $

Field Summary
protected  boolean allowsNull
          Whether the container allows null elements/values.
protected  java.lang.String containsValueStmt
           
protected  org.jpox.store.mapped.DatastoreAdapter dba
          Datastore adapter in use by this store.
protected  org.jpox.store.mapped.DatastoreIdentifier elmIdentifier
          Identifier for elements in JDOQL queries.
protected  boolean iterateUsingDiscriminator
          Flag to set whether the iterator statement will use a discriminator or not.
protected  org.jpox.store.mapped.mapping.JavaTypeMapping keyMapping
          Mapping to the key.
protected  boolean keysAreEmbedded
          Whether the keys are embedded.
protected  boolean keysAreSerialised
          Whether the keys are serialised.
protected  java.lang.String keyType
          Type of the key.
protected  org.jpox.metadata.AbstractClassMetaData kmd
           
protected static org.jpox.util.Localiser LOCALISER
          Localiser for messages.
protected  org.jpox.store.mapped.DatastoreContainerObject mapTable
           
protected  org.jpox.store.mapped.mapping.JavaTypeMapping ownerMapping
          Mapping to the owner of the container.
protected  org.jpox.metadata.AbstractMemberMetaData ownerMemberMetaData
          MetaData for the field/property in the owner with this container.
protected  RDBMSManager storeMgr
          Manager for the store.
protected  org.jpox.store.mapped.mapping.JavaTypeMapping valueMapping
          Mapping to the value.
protected  boolean valuesAreEmbedded
          Whether the values are embedded.
protected  boolean valuesAreSerialised
          Whether the values are serialised.
protected  org.jpox.store.mapped.DatastoreClass valueTable
           
protected  java.lang.String valueType
          Type of the value.
protected  org.jpox.metadata.AbstractClassMetaData vmd
           
 
Constructor Summary
FKMapStore(org.jpox.metadata.AbstractMemberMetaData fmd, RDBMSManager storeMgr, org.jpox.ClassLoaderResolver clr)
          Constructor for an Inverse Map.
 
Method Summary
protected  boolean allowsBatching()
          Convenience method to return if the RDBMS supports batching and the user wants batching.
 void clear(org.jpox.StateManager sm)
          Method to clear the map of all values.
 void clearKeyOfValue(org.jpox.StateManager sm, java.lang.Object key, java.lang.Object oldValue)
          Utility to clear the key of a value from the Map.
 boolean containsKey(org.jpox.StateManager sm, java.lang.Object key)
          Method to check if a key exists in the Map.
 boolean containsValue(org.jpox.StateManager sm, java.lang.Object value)
          Method to check if a value exists in the Map.
 org.jpox.store.scostore.SetStore entrySetStore()
          Accessor for the map entries in the Map.
 java.lang.Object get(org.jpox.StateManager sm, java.lang.Object key)
          Method to return the value for a key.
 org.jpox.store.mapped.expression.QueryExpression getExistsSubquery(org.jpox.store.mapped.expression.QueryExpression qs, org.jpox.store.mapped.mapping.JavaTypeMapping mapping, org.jpox.store.mapped.expression.LogicSetExpression ownerTe, org.jpox.store.mapped.DatastoreIdentifier mapTableAlias)
          Method used where a Query uses map.isEmpty().
protected  org.jpox.store.mapped.expression.QueryExpression getGetStatement(org.jpox.StateManager ownerSm, java.lang.Object key)
          Accessor for the Get statement to retrieve a value from the Map.
 java.lang.String getKeyType()
          Accessor for the key type for storing in this Map.
 org.jpox.store.mapped.mapping.JavaTypeMapping getOwnerMapping()
          Accessor for the owner mapping.
 org.jpox.store.mapped.expression.QueryExpression getSizeSubquery(org.jpox.store.mapped.expression.QueryExpression qs, org.jpox.store.mapped.mapping.JavaTypeMapping mapping, org.jpox.store.mapped.expression.LogicSetExpression ownerTe, org.jpox.store.mapped.DatastoreIdentifier mapTableAlias)
          Query utility to generate a subquery for the size() of the map.
protected  org.jpox.StateManager getStateManagerForEmbeddedPCObject(org.jpox.StateManager sm, java.lang.Object obj, JoinTable table)
          Method to return the StateManager for an embedded PC object (element, key, value).
 org.jpox.store.StoreManager getStoreManager()
          Accessor for the RDBMSManager.
protected  java.lang.String getUpdateEmbeddedKeyStmt(org.jpox.store.mapped.mapping.JavaTypeMapping fieldMapping)
          Generate statement for update the field of an embedded key.
protected  java.lang.String getUpdateEmbeddedValueStmt(org.jpox.store.mapped.mapping.JavaTypeMapping fieldMapping)
          Generate statement for update the field of an embedded value.
protected  java.lang.Object getValue(org.jpox.StateManager sm, java.lang.Object key)
          Method to retrieve a value from the Map given the key.
 java.lang.String getValueType()
          Accessor for the value type for storing in this Map.
protected  void initialiseStatements()
          Method to initialise the statements being used.
protected  boolean isEmbeddedMapping(org.jpox.store.mapped.mapping.JavaTypeMapping mapping)
          Check if the mapping correspond to a non pc object or embedded field
 org.jpox.store.mapped.expression.ScalarExpression joinKeysTo(org.jpox.store.mapped.expression.QueryExpression stmt, org.jpox.store.mapped.expression.QueryExpression parentStmt, org.jpox.store.mapped.mapping.JavaTypeMapping ownerMapping, org.jpox.store.mapped.expression.LogicSetExpression te, org.jpox.store.mapped.DatastoreIdentifier mapTableAlias, java.lang.Class filteredKeyType, org.jpox.store.mapped.expression.ScalarExpression kExpr, org.jpox.store.mapped.DatastoreIdentifier keyTableAlias)
          Utility to create a join for keys to be used in a containsKey() query.
 org.jpox.store.mapped.expression.ScalarExpression[] joinKeysToGet(org.jpox.store.mapped.expression.QueryExpression stmt, org.jpox.store.mapped.expression.QueryExpression parentStmt, org.jpox.store.mapped.mapping.JavaTypeMapping ownerMapping, org.jpox.store.mapped.expression.LogicSetExpression te, org.jpox.store.mapped.DatastoreIdentifier mapTableAlias, java.lang.Class filteredKeyType, org.jpox.store.mapped.DatastoreIdentifier keyTableAlias, org.jpox.store.mapped.DatastoreIdentifier valueTableAlias)
          Used as part of the Querying of Maps where a get(Key) is used.
 org.jpox.store.mapped.expression.ScalarExpression[] joinKeysValuesTo(org.jpox.store.mapped.expression.QueryExpression stmt, org.jpox.store.mapped.expression.QueryExpression parentStmt, org.jpox.store.mapped.mapping.JavaTypeMapping ownerMapping, org.jpox.store.mapped.expression.LogicSetExpression ownerTe, org.jpox.store.mapped.DatastoreIdentifier mapRangeVar, java.lang.Class filteredKeyType, java.lang.Class filteredValueType, org.jpox.store.mapped.expression.ScalarExpression keyExpr, org.jpox.store.mapped.expression.ScalarExpression valExpr, org.jpox.store.mapped.DatastoreIdentifier keyRangeVar, org.jpox.store.mapped.DatastoreIdentifier valueRangeVar)
          Utility to create a join for keys and values to be used in ai containsEntry() query.
 org.jpox.store.mapped.expression.ScalarExpression joinValuesTo(org.jpox.store.mapped.expression.QueryExpression stmt, org.jpox.store.mapped.expression.QueryExpression parentStmt, org.jpox.store.mapped.mapping.JavaTypeMapping ownerMapping, org.jpox.store.mapped.expression.LogicSetExpression ownerTe, org.jpox.store.mapped.DatastoreIdentifier mapRangeVar, java.lang.Class filteredValueType, org.jpox.store.mapped.expression.ScalarExpression valExpr, org.jpox.store.mapped.DatastoreIdentifier valueRangeVar)
          Used as part of the Querying of Maps where a containsValue() is used.
 boolean keysAreEmbedded()
          Accessor for whether the keys are embedded or not.
 boolean keysAreSerialised()
          Accessor for whether the keys are serialised or not.
 org.jpox.store.scostore.SetStore keySetStore(org.jpox.ClassLoaderResolver clr)
          Accessor for the keys in the Map.
 org.jpox.store.mapped.expression.QueryExpression newQueryStatement(org.jpox.StateManager sm, java.lang.String candidateClass, org.jpox.store.mapped.DatastoreIdentifier candidateAlias)
          Utility method to return a new QueryStatement for retrieval of the values of this Map.
 org.jpox.store.query.ResultObjectFactory newResultObjectFactory(org.jpox.StateManager sm, org.jpox.store.mapped.expression.QueryExpression stmt, boolean ignoreCache, boolean useFetchPlan)
          Method to create a Result Object factory for extracting objects from a ResultSet.
protected  int populateEmbeddedKeyFieldsInStatement(org.jpox.StateManager sm, java.lang.Object key, java.sql.PreparedStatement ps, int jdbcPosition, JoinTable joinTable)
          Convenience method to populate the passed PreparedStatement with the field values from the embedded key starting at the specified jdbc position.
protected  int populateEmbeddedValueFieldsInStatement(org.jpox.StateManager sm, java.lang.Object value, java.sql.PreparedStatement ps, int jdbcPosition, JoinTable joinTable)
          Convenience method to populate the passed PreparedStatement with the field values from the embedded value starting at the specified jdbc position.
protected  int populateKeyInStatement(org.jpox.ObjectManager om, java.sql.PreparedStatement ps, java.lang.Object key, int jdbcPosition)
          Convenience method to populate the passed PreparedStatement with the value for the key.
protected  int populateOwnerInStatement(org.jpox.StateManager sm, org.jpox.ObjectManager om, java.sql.PreparedStatement ps, int jdbcPosition)
          Convenience method to populate the passed PreparedStatement with the value from the owner.
protected  int populateValueInStatement(org.jpox.ObjectManager om, java.sql.PreparedStatement ps, java.lang.Object value, int jdbcPosition)
          Convenience method to populate the passed PreparedStatement with the value for the value.
 java.lang.Object put(org.jpox.StateManager sm, java.lang.Object newKey, java.lang.Object newValue)
          Method to put an item in the Map.
 void putAll(org.jpox.StateManager sm, java.util.Map m)
          Method to put all elements from a Map into our Map.
 java.lang.Object remove(org.jpox.StateManager sm, java.lang.Object key)
          Method to remove an item from the map.
protected  void setOwnerMemberMetaData(org.jpox.metadata.AbstractMemberMetaData mmd)
          Method to set the owner field/property MetaData and sets whether null elements/values are allowed.
 boolean updateEmbeddedKey(org.jpox.StateManager sm, java.lang.Object key, int fieldNumber, java.lang.Object newValue)
          Method to update a field of an embedded key.
 boolean updateEmbeddedValue(org.jpox.StateManager sm, java.lang.Object value, int fieldNumber, java.lang.Object newValue)
          Method to update a field of an embedded key.
protected  boolean validateKeyForReading(org.jpox.StateManager sm, java.lang.Object key)
          Utility to validate a key is ok for reading.
protected  void validateKeyForWriting(org.jpox.StateManager sm, java.lang.Object key)
          Utility to validate a key is ok for writing (present in the datastore).
protected  void validateKeyType(org.jpox.ClassLoaderResolver clr, java.lang.Object key)
          Utility to validate the type of a key for storing in the Map.
protected  boolean validateValueForReading(org.jpox.StateManager sm, java.lang.Object value)
          Utility to validate a value is ok for reading.
protected  void validateValueForWriting(org.jpox.StateManager sm, java.lang.Object value)
          Utility to validate a value is ok for writing (present in the datastore).
protected  void validateValueType(org.jpox.ClassLoaderResolver clr, java.lang.Object value)
          Utility to validate the type of a value for storing in the Map.
 boolean valuesAreEmbedded()
          Accessor for whether the values are embedded or not.
 boolean valuesAreSerialised()
          Accessor for whether the values are serialised or not.
 org.jpox.store.scostore.SetStore valueSetStore(org.jpox.ClassLoaderResolver clr)
          Accessor for the values in the Map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jpox.store.scostore.Store
getStoreManager
 

Field Detail

iterateUsingDiscriminator

protected boolean iterateUsingDiscriminator
Flag to set whether the iterator statement will use a discriminator or not.


mapTable

protected org.jpox.store.mapped.DatastoreContainerObject mapTable

valueTable

protected org.jpox.store.mapped.DatastoreClass valueTable

kmd

protected org.jpox.metadata.AbstractClassMetaData kmd

vmd

protected org.jpox.metadata.AbstractClassMetaData vmd

keyMapping

protected org.jpox.store.mapped.mapping.JavaTypeMapping keyMapping
Mapping to the key.


valueMapping

protected org.jpox.store.mapped.mapping.JavaTypeMapping valueMapping
Mapping to the value.


keyType

protected java.lang.String keyType
Type of the key.


valueType

protected java.lang.String valueType
Type of the value.


keysAreEmbedded

protected boolean keysAreEmbedded
Whether the keys are embedded.


keysAreSerialised

protected boolean keysAreSerialised
Whether the keys are serialised.


valuesAreEmbedded

protected boolean valuesAreEmbedded
Whether the values are embedded.


valuesAreSerialised

protected boolean valuesAreSerialised
Whether the values are serialised.


containsValueStmt

protected java.lang.String containsValueStmt

elmIdentifier

protected final org.jpox.store.mapped.DatastoreIdentifier elmIdentifier
Identifier for elements in JDOQL queries.


LOCALISER

protected static final org.jpox.util.Localiser LOCALISER
Localiser for messages.


storeMgr

protected RDBMSManager storeMgr
Manager for the store.


dba

protected org.jpox.store.mapped.DatastoreAdapter dba
Datastore adapter in use by this store.


ownerMapping

protected org.jpox.store.mapped.mapping.JavaTypeMapping ownerMapping
Mapping to the owner of the container.


ownerMemberMetaData

protected org.jpox.metadata.AbstractMemberMetaData ownerMemberMetaData
MetaData for the field/property in the owner with this container.


allowsNull

protected boolean allowsNull
Whether the container allows null elements/values.

Constructor Detail

FKMapStore

public FKMapStore(org.jpox.metadata.AbstractMemberMetaData fmd,
                  RDBMSManager storeMgr,
                  org.jpox.ClassLoaderResolver clr)
Constructor for an Inverse Map.

Parameters:
fmd - Field Meta-Data for the Map field.
storeMgr - The Store Manager we are using.
clr - The ClassLoaderResolver
Method Detail

getGetStatement

protected org.jpox.store.mapped.expression.QueryExpression getGetStatement(org.jpox.StateManager ownerSm,
                                                                           java.lang.Object key)
Accessor for the Get statement to retrieve a value from the Map.

Parameters:
ownerSm - The owner StateManager
key - The search key
Returns:
The QueryStatement.

validateValueType

protected void validateValueType(org.jpox.ClassLoaderResolver clr,
                                 java.lang.Object value)
Utility to validate the type of a value for storing in the Map.

Parameters:
value - The value to check.
clr - The ClassLoaderResolver

put

public java.lang.Object put(org.jpox.StateManager sm,
                            java.lang.Object newKey,
                            java.lang.Object newValue)
Method to put an item in the Map.

Parameters:
sm - State Manager for the map.
newKey - The key to store the value against
newValue - The value to store.
Returns:
The value stored.

remove

public java.lang.Object remove(org.jpox.StateManager sm,
                               java.lang.Object key)
Method to remove an item from the map.

Parameters:
sm - State Manager for the map.
key - Key of the item to remove.
Returns:
The value that was removed.

clear

public void clear(org.jpox.StateManager sm)
Method to clear the map of all values.

Parameters:
sm - State Manager for the map.

clearKeyOfValue

public void clearKeyOfValue(org.jpox.StateManager sm,
                            java.lang.Object key,
                            java.lang.Object oldValue)
Utility to clear the key of a value from the Map. If the key is non nullable, delete the value.

Parameters:
sm - State Manager for the map.
key - Key of the object
oldValue - Value to remove

keySetStore

public org.jpox.store.scostore.SetStore keySetStore(org.jpox.ClassLoaderResolver clr)
Accessor for the keys in the Map.

Parameters:
clr - The ClassLoaderResolver
Returns:
The keys

valueSetStore

public org.jpox.store.scostore.SetStore valueSetStore(org.jpox.ClassLoaderResolver clr)
Accessor for the values in the Map.

Parameters:
clr - The ClassLoaderResolver
Returns:
The values.

entrySetStore

public org.jpox.store.scostore.SetStore entrySetStore()
Accessor for the map entries in the Map.

Returns:
The map entries.

newQueryStatement

public org.jpox.store.mapped.expression.QueryExpression newQueryStatement(org.jpox.StateManager sm,
                                                                          java.lang.String candidateClass,
                                                                          org.jpox.store.mapped.DatastoreIdentifier candidateAlias)
Utility method to return a new QueryStatement for retrieval of the values of this Map.

Parameters:
sm - StateManager for this object
candidateClass - Class for the value end of the link.
candidateAlias - Alias for the candidate
Returns:
The QueryStatement

joinKeysTo

public org.jpox.store.mapped.expression.ScalarExpression joinKeysTo(org.jpox.store.mapped.expression.QueryExpression stmt,
                                                                    org.jpox.store.mapped.expression.QueryExpression parentStmt,
                                                                    org.jpox.store.mapped.mapping.JavaTypeMapping ownerMapping,
                                                                    org.jpox.store.mapped.expression.LogicSetExpression te,
                                                                    org.jpox.store.mapped.DatastoreIdentifier mapTableAlias,
                                                                    java.lang.Class filteredKeyType,
                                                                    org.jpox.store.mapped.expression.ScalarExpression kExpr,
                                                                    org.jpox.store.mapped.DatastoreIdentifier keyTableAlias)
Utility to create a join for keys to be used in a containsKey() query.

Parameters:
stmt - The Query Statement
parentStmt - the parent Query Statement. If there is no parent, parentStmt must be equals to stmt
ownerMapping - Mapping for the owner
te - Table Expression for the owner
mapTableAlias - Alias for the "Map" table.
filteredKeyType - The Class Type for the filtered key
keyTableAlias - The SQL alias to assign to the expression or to the key table.
kExpr - the expression to the key field
Returns:
QueryColumnList with the columns from the key mapping

joinValuesTo

public org.jpox.store.mapped.expression.ScalarExpression joinValuesTo(org.jpox.store.mapped.expression.QueryExpression stmt,
                                                                      org.jpox.store.mapped.expression.QueryExpression parentStmt,
                                                                      org.jpox.store.mapped.mapping.JavaTypeMapping ownerMapping,
                                                                      org.jpox.store.mapped.expression.LogicSetExpression ownerTe,
                                                                      org.jpox.store.mapped.DatastoreIdentifier mapRangeVar,
                                                                      java.lang.Class filteredValueType,
                                                                      org.jpox.store.mapped.expression.ScalarExpression valExpr,
                                                                      org.jpox.store.mapped.DatastoreIdentifier valueRangeVar)
Used as part of the Querying of Maps where a containsValue() is used.

Parameters:
stmt - The Query Statement
parentStmt - the parent Query Statement. If there is no parent, parentStmt must be equals to stmt
ownerMapping - Mapping for the owner
ownerTe - Table Expression for the owner
mapRangeVar - The range variable for the "Map" table.
filteredValueType - The Class Type for the filtered value
valExpr - Table Expression for the value
valueRangeVar - The SQL alias, or "range variable", to assign to the expression or to the value table.
Returns:
QueryColumnList with the columns from the value mapping

joinKeysValuesTo

public org.jpox.store.mapped.expression.ScalarExpression[] joinKeysValuesTo(org.jpox.store.mapped.expression.QueryExpression stmt,
                                                                            org.jpox.store.mapped.expression.QueryExpression parentStmt,
                                                                            org.jpox.store.mapped.mapping.JavaTypeMapping ownerMapping,
                                                                            org.jpox.store.mapped.expression.LogicSetExpression ownerTe,
                                                                            org.jpox.store.mapped.DatastoreIdentifier mapRangeVar,
                                                                            java.lang.Class filteredKeyType,
                                                                            java.lang.Class filteredValueType,
                                                                            org.jpox.store.mapped.expression.ScalarExpression keyExpr,
                                                                            org.jpox.store.mapped.expression.ScalarExpression valExpr,
                                                                            org.jpox.store.mapped.DatastoreIdentifier keyRangeVar,
                                                                            org.jpox.store.mapped.DatastoreIdentifier valueRangeVar)
Utility to create a join for keys and values to be used in ai containsEntry() query.

Parameters:
stmt - The Query Statement to apply the join
parentStmt - the parent Query Statement. If there is no parent, parentStmt must be equals to stmt
ownerMapping - Mapping for the owner
ownerTe - Table Expression for the owner
mapRangeVar - The SQL alias, or "range variable", to assign to the expression or to the main table.
filteredKeyType - The Class Type for the filtered key
filteredValueType - The Class Type for the filtered value
keyExpr - the expression to the key field
valExpr - Table Expression for the value
keyRangeVar - The SQL alias, or "range variable", to assign to the expression or to the key table.
valueRangeVar - The SQL alias, or "range variable", to assign to the expression or to the value table.
Returns:
an array with 2 elements of QueryColumnList. The first element contains the columns from the key mapping and the second element the columns from the value mapping

initialiseStatements

protected void initialiseStatements()
Method to initialise the statements being used. Subclasses should override the getXXXStmt() if they want to use an alternative statement.


keysAreEmbedded

public boolean keysAreEmbedded()
Accessor for whether the keys are embedded or not. If they are PC instances then returns false;

Specified by:
keysAreEmbedded in interface org.jpox.store.scostore.MapStore
Returns:
Whether the keys are embedded

keysAreSerialised

public boolean keysAreSerialised()
Accessor for whether the keys are serialised or not. If they are PC instances then returns false;

Specified by:
keysAreSerialised in interface org.jpox.store.scostore.MapStore
Returns:
Whether the keys are serialised

valuesAreEmbedded

public boolean valuesAreEmbedded()
Accessor for whether the values are embedded or not. If they are PC instances then returns false;

Specified by:
valuesAreEmbedded in interface org.jpox.store.scostore.MapStore
Returns:
Whether the values are embedded

valuesAreSerialised

public boolean valuesAreSerialised()
Accessor for whether the values are serialised or not. If they are PC instances then returns false;

Specified by:
valuesAreSerialised in interface org.jpox.store.scostore.MapStore
Returns:
Whether the values are serialised

getKeyType

public java.lang.String getKeyType()
Accessor for the key type for storing in this Map.

Specified by:
getKeyType in interface org.jpox.store.scostore.MapStore
Returns:
The type of the key

getValueType

public java.lang.String getValueType()
Accessor for the value type for storing in this Map. Types inherited from this (base) type can also be stored as values.

Specified by:
getValueType in interface org.jpox.store.scostore.MapStore
Returns:
The type of the value (base class).

containsKey

public boolean containsKey(org.jpox.StateManager sm,
                           java.lang.Object key)
Method to check if a key exists in the Map.

Specified by:
containsKey in interface org.jpox.store.scostore.MapStore
Parameters:
sm - State Manager for the map
key - The key to check for.
Returns:
Whether the key exists in the Map.

containsValue

public boolean containsValue(org.jpox.StateManager sm,
                             java.lang.Object value)
Method to check if a value exists in the Map.

Specified by:
containsValue in interface org.jpox.store.scostore.MapStore
Parameters:
sm - State Manager for the map
value - The value to check for.
Returns:
Whether the value exists in the Map.

get

public java.lang.Object get(org.jpox.StateManager sm,
                            java.lang.Object key)
Method to return the value for a key.

Specified by:
get in interface org.jpox.store.scostore.MapStore
Parameters:
sm - State Manager for the Map.
key - The key of the object to retrieve.
Returns:
The value for this key.

putAll

public void putAll(org.jpox.StateManager sm,
                   java.util.Map m)
Method to put all elements from a Map into our Map.

Specified by:
putAll in interface org.jpox.store.scostore.MapStore
Parameters:
sm - State Manager for the Map
m - The Map to add

validateKeyType

protected void validateKeyType(org.jpox.ClassLoaderResolver clr,
                               java.lang.Object key)
Utility to validate the type of a key for storing in the Map.

Parameters:
clr - The ClassLoaderResolver
key - The key to check.

validateKeyForReading

protected boolean validateKeyForReading(org.jpox.StateManager sm,
                                        java.lang.Object key)
Utility to validate a key is ok for reading.

Parameters:
sm - State Manager for the map.
key - The key to check.
Returns:
Whether it is validated.

validateValueForReading

protected boolean validateValueForReading(org.jpox.StateManager sm,
                                          java.lang.Object value)
Utility to validate a value is ok for reading.

Parameters:
sm - State Manager for the map.
value - The value to check.
Returns:
Whether it is validated.

validateKeyForWriting

protected void validateKeyForWriting(org.jpox.StateManager sm,
                                     java.lang.Object key)
Utility to validate a key is ok for writing (present in the datastore).

Parameters:
sm - State Manager for the map.
key - The key to check.

validateValueForWriting

protected void validateValueForWriting(org.jpox.StateManager sm,
                                       java.lang.Object value)
Utility to validate a value is ok for writing (present in the datastore).

Parameters:
sm - State Manager for the map.
value - The value to check.

getValue

protected java.lang.Object getValue(org.jpox.StateManager sm,
                                    java.lang.Object key)
                             throws java.util.NoSuchElementException
Method to retrieve a value from the Map given the key.

Parameters:
sm - State Manager for the map.
key - The key to retrieve the value for.
Returns:
The value for this key
Throws:
java.util.NoSuchElementException - if the value for the key was not found

populateKeyInStatement

protected int populateKeyInStatement(org.jpox.ObjectManager om,
                                     java.sql.PreparedStatement ps,
                                     java.lang.Object key,
                                     int jdbcPosition)
Convenience method to populate the passed PreparedStatement with the value for the key. Not used with embedded PC elements.

Parameters:
om - Object Manager
ps - The PreparedStatement
key - The key
jdbcPosition - Position in JDBC statement to populate
Returns:
The next position in the JDBC statement

populateValueInStatement

protected int populateValueInStatement(org.jpox.ObjectManager om,
                                       java.sql.PreparedStatement ps,
                                       java.lang.Object value,
                                       int jdbcPosition)
Convenience method to populate the passed PreparedStatement with the value for the value. Not used with embedded PC elements.

Parameters:
om - Object Manager
ps - The PreparedStatement
value - The value
jdbcPosition - Position in JDBC statement to populate
Returns:
The next position in the JDBC statement

populateEmbeddedKeyFieldsInStatement

protected int populateEmbeddedKeyFieldsInStatement(org.jpox.StateManager sm,
                                                   java.lang.Object key,
                                                   java.sql.PreparedStatement ps,
                                                   int jdbcPosition,
                                                   JoinTable joinTable)
Convenience method to populate the passed PreparedStatement with the field values from the embedded key starting at the specified jdbc position.

Parameters:
sm - State Manager of the owning container
key - The embedded key
ps - The PreparedStatement
jdbcPosition - JDBC position in the statement to start at
joinTable - The Join table where the values are embedded
Returns:
The next JDBC position

populateEmbeddedValueFieldsInStatement

protected int populateEmbeddedValueFieldsInStatement(org.jpox.StateManager sm,
                                                     java.lang.Object value,
                                                     java.sql.PreparedStatement ps,
                                                     int jdbcPosition,
                                                     JoinTable joinTable)
Convenience method to populate the passed PreparedStatement with the field values from the embedded value starting at the specified jdbc position.

Parameters:
sm - State Manager of the owning container
value - The embedded value
ps - The PreparedStatement
jdbcPosition - JDBC position in the statement to start at
joinTable - The Join table where the values are embedded
Returns:
The next JDBC position

updateEmbeddedKey

public boolean updateEmbeddedKey(org.jpox.StateManager sm,
                                 java.lang.Object key,
                                 int fieldNumber,
                                 java.lang.Object newValue)
Method to update a field of an embedded key.

Specified by:
updateEmbeddedKey in interface org.jpox.store.scostore.MapStore
Parameters:
sm - State Manager of the owner
key - The key to update
fieldNumber - The number of the field to update
newValue - The new value

updateEmbeddedValue

public boolean updateEmbeddedValue(org.jpox.StateManager sm,
                                   java.lang.Object value,
                                   int fieldNumber,
                                   java.lang.Object newValue)
Method to update a field of an embedded key.

Specified by:
updateEmbeddedValue in interface org.jpox.store.scostore.MapStore
Parameters:
sm - State Manager of the owner
value - The value to update
fieldNumber - The number of the field to update
newValue - The new value

getUpdateEmbeddedKeyStmt

protected java.lang.String getUpdateEmbeddedKeyStmt(org.jpox.store.mapped.mapping.JavaTypeMapping fieldMapping)
Generate statement for update the field of an embedded key.
 UPDATE MAPTABLE
 SET EMBEDDEDKEYCOL1 = ?
 WHERE OWNERCOL=?
 AND EMBEDDEDKEYCOL1 = ?
 AND EMBEDDEDKEYCOL2 = ? ...
 

Parameters:
fieldMapping - The mapping for the field to be updated
Returns:
Statement for updating an embedded key in the Set

getUpdateEmbeddedValueStmt

protected java.lang.String getUpdateEmbeddedValueStmt(org.jpox.store.mapped.mapping.JavaTypeMapping fieldMapping)
Generate statement for update the field of an embedded value.
 UPDATE MAPTABLE
 SET EMBEDDEDVALUECOL1 = ?
 WHERE OWNERCOL=?
 AND EMBEDDEDVALUECOL1 = ?
 AND EMBEDDEDVALUECOL2 = ? ...
 

Parameters:
fieldMapping - The mapping for the field to be updated
Returns:
Statement for updating an embedded value in the Set

newResultObjectFactory

public org.jpox.store.query.ResultObjectFactory newResultObjectFactory(org.jpox.StateManager sm,
                                                                       org.jpox.store.mapped.expression.QueryExpression stmt,
                                                                       boolean ignoreCache,
                                                                       boolean useFetchPlan)
Method to create a Result Object factory for extracting objects from a ResultSet.

Specified by:
newResultObjectFactory in interface org.jpox.store.mapped.scostore.MapStoreQueryable
Parameters:
sm - State Manager of owner field
stmt - The Query statement
ignoreCache - Whether to ignore the cache
useFetchPlan - Whether to retrieve the fetch plan fields or DFG
Returns:
The Result Object factory

getExistsSubquery

public org.jpox.store.mapped.expression.QueryExpression getExistsSubquery(org.jpox.store.mapped.expression.QueryExpression qs,
                                                                          org.jpox.store.mapped.mapping.JavaTypeMapping mapping,
                                                                          org.jpox.store.mapped.expression.LogicSetExpression ownerTe,
                                                                          org.jpox.store.mapped.DatastoreIdentifier mapTableAlias)
Method used where a Query uses map.isEmpty().

Specified by:
getExistsSubquery in interface org.jpox.store.mapped.scostore.MapStoreQueryable
Parameters:
qs - The QueryStatement
mapping - The mapping of the java type
ownerTe - The owner table expression
mapTableAlias - The aliasfor the "Map" table.
Returns:
A subquery

getSizeSubquery

public org.jpox.store.mapped.expression.QueryExpression getSizeSubquery(org.jpox.store.mapped.expression.QueryExpression qs,
                                                                        org.jpox.store.mapped.mapping.JavaTypeMapping mapping,
                                                                        org.jpox.store.mapped.expression.LogicSetExpression ownerTe,
                                                                        org.jpox.store.mapped.DatastoreIdentifier mapTableAlias)
Query utility to generate a subquery for the size() of the map.

Specified by:
getSizeSubquery in interface org.jpox.store.mapped.scostore.MapStoreQueryable
Parameters:
qs - The query statement
mapping - mapping of the field
ownerTe - Expression for the table
mapTableAlias - alias for the map table
Returns:
The query statement

joinKeysToGet

public org.jpox.store.mapped.expression.ScalarExpression[] joinKeysToGet(org.jpox.store.mapped.expression.QueryExpression stmt,
                                                                         org.jpox.store.mapped.expression.QueryExpression parentStmt,
                                                                         org.jpox.store.mapped.mapping.JavaTypeMapping ownerMapping,
                                                                         org.jpox.store.mapped.expression.LogicSetExpression te,
                                                                         org.jpox.store.mapped.DatastoreIdentifier mapTableAlias,
                                                                         java.lang.Class filteredKeyType,
                                                                         org.jpox.store.mapped.DatastoreIdentifier keyTableAlias,
                                                                         org.jpox.store.mapped.DatastoreIdentifier valueTableAlias)
Used as part of the Querying of Maps where a get(Key) is used.

Specified by:
joinKeysToGet in interface org.jpox.store.mapped.scostore.MapStoreQueryable
Parameters:
stmt - The Query Statement to apply the join
parentStmt - the parent Query Statement. If there is no parent, parentStmt must be equals to stmt
ownerMapping - Mapping for the owner.
te - Table Expression for the owner
mapTableAlias - The SQL alias to assign to the expression or to the main table.
filteredKeyType - The Class Type for the filtered key
keyTableAlias - The SQL alias to assign to the expression or to the key table.
valueTableAlias - The SQL alias to assign to the expression or to the value table.
Returns:
an array with 2 elements of QueryColumnList. The first element contains the columns from the key mapping and the second element the columns from the value mapping

setOwnerMemberMetaData

protected void setOwnerMemberMetaData(org.jpox.metadata.AbstractMemberMetaData mmd)
Method to set the owner field/property MetaData and sets whether null elements/values are allowed.

Parameters:
mmd - MetaData for the field/property owning this backing store.

getStoreManager

public org.jpox.store.StoreManager getStoreManager()
Accessor for the RDBMSManager.

Returns:
The RDBMSManager.

getOwnerMapping

public org.jpox.store.mapped.mapping.JavaTypeMapping getOwnerMapping()
Accessor for the owner mapping.

Returns:
Owner mapping.

isEmbeddedMapping

protected boolean isEmbeddedMapping(org.jpox.store.mapped.mapping.JavaTypeMapping mapping)
Check if the mapping correspond to a non pc object or embedded field

Parameters:
mapping - the mapping
Returns:
true if the field is embedded into one column

populateOwnerInStatement

protected int populateOwnerInStatement(org.jpox.StateManager sm,
                                       org.jpox.ObjectManager om,
                                       java.sql.PreparedStatement ps,
                                       int jdbcPosition)
Convenience method to populate the passed PreparedStatement with the value from the owner.

Parameters:
sm - State Manager
om - Object Manager
ps - The PreparedStatement
jdbcPosition - Position in JDBC statement to populate
Returns:
The next position in the JDBC statement

getStateManagerForEmbeddedPCObject

protected org.jpox.StateManager getStateManagerForEmbeddedPCObject(org.jpox.StateManager sm,
                                                                   java.lang.Object obj,
                                                                   JoinTable table)
Method to return the StateManager for an embedded PC object (element, key, value). It creates one if the element is not currently managed.

Parameters:
sm - State Manager of the owner
obj - The embedded PC object
table - Join table where the objects are stored
Returns:
The state manager

allowsBatching

protected boolean allowsBatching()
Convenience method to return if the RDBMS supports batching and the user wants batching.

Returns:
If batching of statements is permissible


Copyright © -2008 . All Rights Reserved.