|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jpox.store.rdbms.scostore.BaseContainerStore
org.jpox.store.rdbms.scostore.AbstractMapStore
org.jpox.store.rdbms.scostore.FKMapStore
Representation of an "inverse" (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. There are 2 possible uses here
Field Summary | |
protected java.lang.String |
containsValueStmt
|
protected DatastoreAdapter |
dba
Datastore adapter in use by this store. |
protected 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 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 AbstractClassMetaData |
kmd
|
protected static Localiser |
LOCALISER
Localiser for messages. |
protected DatastoreContainerObject |
mapTable
|
protected AbstractPropertyMetaData |
ownerFieldMetaData
MetaData for the field in the owner with this container. |
protected JavaTypeMapping |
ownerMapping
Mapping to the owner of the container. |
protected StoreManager |
storeMgr
Manager for the store. |
protected DatastoreIdentifier |
thisIdentifier
Identifier for the container in JDOQL queries. |
protected JavaTypeMapping |
valueMapping
Mapping to the value. |
protected boolean |
valuesAreEmbedded
Whether the values are embedded. |
protected boolean |
valuesAreSerialised
Whether the values are serialised. |
protected DatastoreClass |
valueTable
|
protected java.lang.String |
valueType
Type of the value. |
protected AbstractClassMetaData |
vmd
|
Constructor Summary | |
FKMapStore(AbstractPropertyMetaData fmd,
RDBMSManager storeMgr,
ClassLoaderResolver clr)
Constructor for an Inverse Map. |
Method Summary | |
void |
clear(StateManager sm)
Method to clear the map of all values. |
void |
clearKeyOfValue(StateManager sm,
java.lang.Object key,
java.lang.Object oldValue)
Utility to clear the key of a value from the Map. |
boolean |
containsKey(StateManager sm,
java.lang.Object key)
Method to check if a key exists in the Map. |
boolean |
containsValue(StateManager sm,
java.lang.Object value)
Method to check if a value exists in the Map. |
SetStore |
entrySetStore()
Accessor for the map entries in the Map. |
protected java.sql.ResultSet |
executeQuery(java.lang.String stmt,
java.sql.PreparedStatement ps)
Method to execute a PreparedStatement query, and return the ResultSet. |
protected int |
executeUpdate(java.lang.String stmt,
java.sql.PreparedStatement ps)
Method to execute a PreparedStatement. |
java.lang.Object |
get(StateManager sm,
java.lang.Object key)
Method to return the value for a key. |
QueryExpression |
getExistsSubquery(QueryExpression qs,
JavaTypeMapping mapping,
LogicSetExpression ownerTe,
DatastoreIdentifier mapRangeVar)
Method used where a Query uses map.isEmpty(). |
protected QueryExpression |
getGetStatement(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. |
JavaTypeMapping |
getOwnerMapping()
Accessor for the owner mapping. |
QueryExpression |
getSizeSubquery(QueryExpression qs,
JavaTypeMapping mapping,
LogicSetExpression ownerTe,
DatastoreIdentifier mapRangeVar)
JDOQL utility to generate a subquery for the size() of the map. |
protected StateManager |
getStateManagerForEmbeddedPCObject(StateManager sm,
java.lang.Object obj,
JoinTable table)
Method to return the StateManager for an embedded PC object (element, key, value). |
StoreManager |
getStoreManager()
Accessor for the RDBMSManager. |
protected java.lang.String |
getUpdateEmbeddedKeyStmt(JavaTypeMapping fieldMapping)
Generate statement for update the field of an embedded key. |
protected java.lang.String |
getUpdateEmbeddedValueStmt(JavaTypeMapping fieldMapping)
Generate statement for update the field of an embedded value. |
protected java.lang.Object |
getValue(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(JavaTypeMapping mapping)
Check if the mapping correspond to a non pc object or embedded field |
ScalarExpression |
joinKeysTo(QueryExpression stmt,
QueryExpression parentStmt,
JavaTypeMapping ownerMapping,
LogicSetExpression te,
DatastoreIdentifier mapRangeVar,
java.lang.Class filteredKeyType,
ScalarExpression kExpr,
DatastoreIdentifier keyRangeVar)
Utility to create a join for keys to be used in a containsKey() query. |
ScalarExpression[] |
joinKeysToGet(QueryExpression stmt,
QueryExpression parentStmt,
JavaTypeMapping ownerMapping,
LogicSetExpression te,
DatastoreIdentifier mapRangeVar,
java.lang.Class filteredKeyType,
DatastoreIdentifier keyRangeVar,
DatastoreIdentifier valueRangeVar)
Used as part of the Querying of Maps where a get(Key) is used. |
ScalarExpression[] |
joinKeysValuesTo(QueryExpression stmt,
QueryExpression parentStmt,
JavaTypeMapping ownerMapping,
LogicSetExpression ownerTe,
DatastoreIdentifier mapRangeVar,
java.lang.Class filteredKeyType,
java.lang.Class filteredValueType,
ScalarExpression keyExpr,
ScalarExpression valExpr,
DatastoreIdentifier keyRangeVar,
DatastoreIdentifier valueRangeVar)
Utility to create a join for keys and values to be used in ai containsEntry() query. |
ScalarExpression |
joinValuesTo(QueryExpression stmt,
QueryExpression parentStmt,
JavaTypeMapping ownerMapping,
LogicSetExpression ownerTe,
DatastoreIdentifier mapRangeVar,
java.lang.Class filteredValueType,
ScalarExpression valExpr,
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. |
SetStore |
keySetStore(ClassLoaderResolver clr)
Accessor for the keys in the Map. |
QueryExpression |
newQueryStatement(StateManager sm,
java.lang.String candidateClass)
Utility method to return a new QueryStatement for retrieval of the elements of this Map. |
Query.ResultObjectFactory |
newResultObjectFactory(StateManager sm,
QueryExpression stmt,
boolean ignoreCache,
boolean useFetchPlan)
Method to create a Result Object factory for extracting objects from a ResultSet. |
protected int |
populateEmbeddedKeyFieldsInStatement(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(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(PersistenceManager pm,
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(StateManager sm,
PersistenceManager pm,
java.sql.PreparedStatement ps,
int jdbcPosition)
Convenience method to populate the passed PreparedStatement with the value from the owner. |
protected int |
populateValueInStatement(PersistenceManager pm,
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(StateManager sm,
java.lang.Object newKey,
java.lang.Object newValue)
Method to put an item in the Map. |
void |
putAll(StateManager sm,
java.util.Map m)
Method to put all elements from a Map into our Map. |
java.lang.Object |
remove(StateManager sm,
java.lang.Object key)
Method to remove an item from the map. |
boolean |
updateEmbeddedKey(StateManager sm,
java.lang.Object key,
int fieldNumber,
java.lang.Object newValue)
Method to update a field of an embedded key. |
boolean |
updateEmbeddedValue(StateManager sm,
java.lang.Object value,
int fieldNumber,
java.lang.Object newValue)
Method to update a field of an embedded key. |
protected boolean |
validateKeyForReading(StateManager sm,
java.lang.Object key)
Utility to validate a key is ok for reading. |
protected void |
validateKeyForWriting(StateManager sm,
java.lang.Object key)
Method to check if an key is already persistent, or is managed by a different Persistencemanager. |
protected void |
validateKeyType(ClassLoaderResolver clr,
java.lang.Object key)
Utility to validate the type of a key for storing in the Map. |
protected boolean |
validateValueForReading(StateManager sm,
java.lang.Object value)
Utility to validate a value is ok for reading. |
protected void |
validateValueForWriting(StateManager sm,
java.lang.Object value)
Method to check if an value is already persistent, or is managed by a different Persistencemanager. |
protected void |
validateValueType(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. |
SetStore |
valueSetStore(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 |
getOwnerMapping, getStoreManager |
Field Detail |
protected boolean iterateUsingDiscriminator
protected DatastoreContainerObject mapTable
protected DatastoreClass valueTable
protected AbstractClassMetaData kmd
protected AbstractClassMetaData vmd
protected JavaTypeMapping keyMapping
protected JavaTypeMapping valueMapping
protected java.lang.String keyType
protected java.lang.String valueType
protected boolean keysAreEmbedded
protected boolean keysAreSerialised
protected boolean valuesAreEmbedded
protected boolean valuesAreSerialised
protected java.lang.String containsValueStmt
protected final DatastoreIdentifier elmIdentifier
protected static final Localiser LOCALISER
protected StoreManager storeMgr
protected DatastoreAdapter dba
protected JavaTypeMapping ownerMapping
protected AbstractPropertyMetaData ownerFieldMetaData
protected final DatastoreIdentifier thisIdentifier
Constructor Detail |
public FKMapStore(AbstractPropertyMetaData fmd, RDBMSManager storeMgr, ClassLoaderResolver clr)
fmd
- Field Meta-Data for the Map field.storeMgr
- The Store Manager we are using.clr
- The ClassLoaderResolverMethod Detail |
protected QueryExpression getGetStatement(StateManager ownerSm, java.lang.Object key)
ownerSm
- The owner StateManagerkey
- The search key
protected void validateValueType(ClassLoaderResolver clr, java.lang.Object value)
value
- The value to check.clr
- The ClassLoaderResolverprotected void validateValueForWriting(StateManager sm, java.lang.Object value)
sm
- The state manager of this collectionvalue
- The valueprotected void validateKeyForWriting(StateManager sm, java.lang.Object key)
sm
- The state manager of this collectionkey
- The keypublic java.lang.Object put(StateManager sm, java.lang.Object newKey, java.lang.Object newValue)
sm
- State Manager for the map.newKey
- The key to store the value againstnewValue
- The value to store.
public java.lang.Object remove(StateManager sm, java.lang.Object key)
sm
- State Manager for the map.key
- Key of the item to remove.
public void clear(StateManager sm)
sm
- State Manager for the map.public void clearKeyOfValue(StateManager sm, java.lang.Object key, java.lang.Object oldValue)
sm
- State Manager for the map.key
- Key of the objectoldValue
- Value to removepublic SetStore keySetStore(ClassLoaderResolver clr)
clr
- The ClassLoaderResolver
public SetStore valueSetStore(ClassLoaderResolver clr)
clr
- The ClassLoaderResolver
public SetStore entrySetStore()
public QueryExpression newQueryStatement(StateManager sm, java.lang.String candidateClass)
sm
- StateManager for this objectcandidateClass
- Class for the value end of the link.
public ScalarExpression joinKeysTo(QueryExpression stmt, QueryExpression parentStmt, JavaTypeMapping ownerMapping, LogicSetExpression te, DatastoreIdentifier mapRangeVar, java.lang.Class filteredKeyType, ScalarExpression kExpr, DatastoreIdentifier keyRangeVar)
stmt
- The Query StatementparentStmt
- the parent Query Statement. If there is no parent, parentStmt
must be equals to stmt
ownerMapping
- Mapping for the ownerte
- Table Expression for the ownermapRangeVar
- The range variable for the "Map" table.filteredKeyType
- The Class Type for the filtered keykeyRangeVar
- The SQL alias, or "range variable", to assign to the
expression or to the key table.kExpr
- the expression to the key field
public ScalarExpression joinValuesTo(QueryExpression stmt, QueryExpression parentStmt, JavaTypeMapping ownerMapping, LogicSetExpression ownerTe, DatastoreIdentifier mapRangeVar, java.lang.Class filteredValueType, ScalarExpression valExpr, DatastoreIdentifier valueRangeVar)
stmt
- The Query StatementparentStmt
- the parent Query Statement. If there is no parent, parentStmt
must be equals to stmt
ownerMapping
- Mapping for the ownerownerTe
- Table Expression for the ownermapRangeVar
- The range variable for the "Map" table.filteredValueType
- The Class Type for the filtered valuevalExpr
- Table Expression for the valuevalueRangeVar
- The SQL alias, or "range variable", to assign to the
expression or to the value table.
public ScalarExpression[] joinKeysValuesTo(QueryExpression stmt, QueryExpression parentStmt, JavaTypeMapping ownerMapping, LogicSetExpression ownerTe, DatastoreIdentifier mapRangeVar, java.lang.Class filteredKeyType, java.lang.Class filteredValueType, ScalarExpression keyExpr, ScalarExpression valExpr, DatastoreIdentifier keyRangeVar, DatastoreIdentifier valueRangeVar)
stmt
- The Query Statement to apply the joinparentStmt
- the parent Query Statement. If there is no parent, parentStmt
must be equals to stmt
ownerMapping
- Mapping for the ownerownerTe
- Table Expression for the ownermapRangeVar
- The SQL alias, or "range variable", to assign to the
expression or to the main table.filteredKeyType
- The Class Type for the filtered keyfilteredValueType
- The Class Type for the filtered valuekeyExpr
- the expression to the key fieldvalExpr
- Table Expression for the valuekeyRangeVar
- 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.
protected void initialiseStatements()
public boolean keysAreEmbedded()
keysAreEmbedded
in interface MapStore
public boolean keysAreSerialised()
keysAreSerialised
in interface MapStore
public boolean valuesAreEmbedded()
valuesAreEmbedded
in interface MapStore
public boolean valuesAreSerialised()
valuesAreSerialised
in interface MapStore
public java.lang.String getKeyType()
getKeyType
in interface MapStore
public java.lang.String getValueType()
getValueType
in interface MapStore
public boolean containsKey(StateManager sm, java.lang.Object key)
containsKey
in interface MapStore
sm
- State Manager for the mapkey
- The key to check for.
public boolean containsValue(StateManager sm, java.lang.Object value)
containsValue
in interface MapStore
sm
- State Manager for the mapvalue
- The value to check for.
public java.lang.Object get(StateManager sm, java.lang.Object key)
get
in interface MapStore
sm
- State Manager for the Map.key
- The key of the object to retrieve.
public void putAll(StateManager sm, java.util.Map m)
putAll
in interface MapStore
sm
- State Manager for the Mapm
- The Map to addprotected void validateKeyType(ClassLoaderResolver clr, java.lang.Object key)
clr
- The ClassLoaderResolverkey
- The key to check.protected boolean validateKeyForReading(StateManager sm, java.lang.Object key)
sm
- State Manager for the map.key
- The key to check.
protected boolean validateValueForReading(StateManager sm, java.lang.Object value)
sm
- State Manager for the map.value
- The value to check.
protected java.lang.Object getValue(StateManager sm, java.lang.Object key) throws java.util.NoSuchElementException
sm
- State Manager for the map.key
- The key to retrieve the value for.
java.util.NoSuchElementException
- if the value for the key was not foundprotected int populateKeyInStatement(PersistenceManager pm, java.sql.PreparedStatement ps, java.lang.Object key, int jdbcPosition)
pm
- Persistence Managerps
- The PreparedStatementkey
- The keyjdbcPosition
- Position in JDBC statement to populate
protected int populateValueInStatement(PersistenceManager pm, java.sql.PreparedStatement ps, java.lang.Object value, int jdbcPosition)
pm
- Persistence Managerps
- The PreparedStatementvalue
- The valuejdbcPosition
- Position in JDBC statement to populate
protected int populateEmbeddedKeyFieldsInStatement(StateManager sm, java.lang.Object key, java.sql.PreparedStatement ps, int jdbcPosition, JoinTable joinTable)
sm
- State Manager of the owning containerkey
- The embedded keyps
- The PreparedStatementjdbcPosition
- JDBC position in the statement to start atjoinTable
- The Join table where the values are embedded
protected int populateEmbeddedValueFieldsInStatement(StateManager sm, java.lang.Object value, java.sql.PreparedStatement ps, int jdbcPosition, JoinTable joinTable)
sm
- State Manager of the owning containervalue
- The embedded valueps
- The PreparedStatementjdbcPosition
- JDBC position in the statement to start atjoinTable
- The Join table where the values are embedded
public boolean updateEmbeddedKey(StateManager sm, java.lang.Object key, int fieldNumber, java.lang.Object newValue)
updateEmbeddedKey
in interface MapStore
sm
- State Manager of the ownerkey
- The key to updatefieldNumber
- The number of the field to updatenewValue
- The new value
public boolean updateEmbeddedValue(StateManager sm, java.lang.Object value, int fieldNumber, java.lang.Object newValue)
updateEmbeddedValue
in interface MapStore
sm
- State Manager of the ownervalue
- The value to updatefieldNumber
- The number of the field to updatenewValue
- The new value
protected java.lang.String getUpdateEmbeddedKeyStmt(JavaTypeMapping fieldMapping)
UPDATE MAPTABLE SET EMBEDDEDKEYCOL1 = ? WHERE OWNERCOL=? AND EMBEDDEDKEYCOL1 = ? AND EMBEDDEDKEYCOL2 = ? ...
fieldMapping
- The mapping for the field to be updated
protected java.lang.String getUpdateEmbeddedValueStmt(JavaTypeMapping fieldMapping)
UPDATE MAPTABLE SET EMBEDDEDVALUECOL1 = ? WHERE OWNERCOL=? AND EMBEDDEDVALUECOL1 = ? AND EMBEDDEDVALUECOL2 = ? ...
fieldMapping
- The mapping for the field to be updated
public Query.ResultObjectFactory newResultObjectFactory(StateManager sm, QueryExpression stmt, boolean ignoreCache, boolean useFetchPlan)
newResultObjectFactory
in interface MapStore
sm
- State Manager of owner fieldstmt
- The Query statementignoreCache
- Whether to ignore the cacheuseFetchPlan
- Whether to retrieve the fetch plan fields or DFG
public QueryExpression getExistsSubquery(QueryExpression qs, JavaTypeMapping mapping, LogicSetExpression ownerTe, DatastoreIdentifier mapRangeVar)
getExistsSubquery
in interface MapStore
qs
- The QueryStatementmapping
- The mapping of the java typeownerTe
- The owner table expressionmapRangeVar
- The range variable for the "Map" table.
public QueryExpression getSizeSubquery(QueryExpression qs, JavaTypeMapping mapping, LogicSetExpression ownerTe, DatastoreIdentifier mapRangeVar)
getSizeSubquery
in interface MapStore
qs
- The JDOQL query statementmapping
- mapping of the fieldownerTe
- Expression for the tablemapRangeVar
- range variable for the map
public ScalarExpression[] joinKeysToGet(QueryExpression stmt, QueryExpression parentStmt, JavaTypeMapping ownerMapping, LogicSetExpression te, DatastoreIdentifier mapRangeVar, java.lang.Class filteredKeyType, DatastoreIdentifier keyRangeVar, DatastoreIdentifier valueRangeVar)
joinKeysToGet
in interface MapStore
stmt
- The Query Statement to apply the joinparentStmt
- 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 ownermapRangeVar
- The SQL alias, or "range variable", to assign to the
expression or to the main table.filteredKeyType
- The Class Type for the filtered keykeyRangeVar
- 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.
public StoreManager getStoreManager()
public JavaTypeMapping getOwnerMapping()
protected int executeUpdate(java.lang.String stmt, java.sql.PreparedStatement ps) throws java.sql.SQLException
stmt
- The statement textps
- The Prepared Statement
java.sql.SQLException
- Thrown if an error occursprotected java.sql.ResultSet executeQuery(java.lang.String stmt, java.sql.PreparedStatement ps) throws java.sql.SQLException
stmt
- The statement textps
- The Prepared Statement
java.sql.SQLException
- Thrown if an error occursprotected boolean isEmbeddedMapping(JavaTypeMapping mapping)
mapping
- the mapping
protected int populateOwnerInStatement(StateManager sm, PersistenceManager pm, java.sql.PreparedStatement ps, int jdbcPosition)
sm
- State Managerpm
- Persistence Managerps
- The PreparedStatementjdbcPosition
- Position in JDBC statement to populate
protected StateManager getStateManagerForEmbeddedPCObject(StateManager sm, java.lang.Object obj, JoinTable table)
sm
- State Manager of the ownerobj
- The embedded PC objecttable
- Join table where the objects are stored
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |