|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jpox.store.rdbms.scostore.ElementContainerStore
public abstract class ElementContainerStore
Representation of the store of an element-based container. This is used to represent either a collection or an array. There are 3 types of situation that we try to cater for with respect to elements.
| Nested Class Summary | |
|---|---|
class |
ElementContainerStore.ElementInfo
Inner class wrapping the information required for a valid element type. |
| Field Summary | |
|---|---|
protected java.lang.String |
addStmt
Statement for adding an element to the container. |
protected boolean |
allowsNull
Whether the container allows null elements/values. |
protected java.lang.String |
clearStmt
Statement for clearing the container. |
protected org.jpox.ClassLoaderResolver |
clr
ClassLoader resolver. |
protected org.jpox.store.mapped.DatastoreContainerObject |
containerTable
Table containing the link between owner and element. |
protected org.jpox.store.mapped.DatastoreAdapter |
dba
Datastore adapter in use by this store. |
protected ElementContainerStore.ElementInfo[] |
elementInfo
Information for the elements of this container. |
protected boolean |
elementIsPersistentInterface
Whether the element is of a persistent-interface (defined using " |
protected org.jpox.store.mapped.mapping.JavaTypeMapping |
elementMapping
Mapping for the element. |
protected boolean |
elementsAreEmbedded
Whether the elements are embedded. |
protected boolean |
elementsAreSerialised
Whether the elements are serialised. |
protected java.lang.String |
elementType
Type of the element. |
protected org.jpox.store.mapped.DatastoreIdentifier |
elmIdentifier
Identifier for elements in JDOQL queries. |
protected org.jpox.metadata.AbstractClassMetaData |
emd
MetaData for the "element-type" class. |
protected boolean |
iterateUsingDiscriminator
Flag to set whether the iterator statement will use a discriminator or not. |
protected static org.jpox.util.Localiser |
LOCALISER
Localiser for messages. |
protected org.jpox.store.mapped.mapping.JavaTypeMapping |
orderMapping
Mapping for an ordering column to allow for duplicates in the container. |
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 org.jpox.store.mapped.mapping.JavaTypeMapping |
relationDiscriminatorMapping
Optional mapping to distinguish elements of one collection from another when sharing the join table. |
protected java.lang.String |
relationDiscriminatorValue
Value to use to discriminate between elements of this collection from others using the same join table. |
protected java.lang.String |
removeStmt
Statement for removing an element from the container. |
protected RDBMSManager |
storeMgr
Manager for the store. |
protected boolean |
usingDiscriminatorInSizeStmt
Whether we are using a discriminator in the "size" statement. |
| Constructor Summary | |
|---|---|
protected |
ElementContainerStore(org.jpox.store.StoreManager storeMgr,
org.jpox.ClassLoaderResolver clr)
Constructor. |
| Method Summary | |
|---|---|
protected boolean |
allowsBatching()
Convenience method to return if the RDBMS supports batching and the user wants batching. |
void |
clear(org.jpox.StateManager ownerSM)
Clear the association from owner to all elements. |
protected java.lang.String |
getAddStmt()
Generates the statement for adding items. |
protected java.lang.String |
getClearStmt()
Generate statement for clearing the container. |
protected ElementContainerStore.ElementInfo[] |
getElementInformationForClass()
Convenience method to find the element information relating to the element type. |
java.lang.String |
getElementType()
Accessor for the element type stored in this container. |
org.jpox.store.mapped.mapping.JavaTypeMapping |
getOwnerMapping()
Accessor for the owner mapping. |
protected java.lang.String |
getSizeStmt()
Generate statement for getting the size of the container. |
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. |
boolean |
hasOrderMapping()
Accessor for whether the store has an order mapping, to allow for duplicates or ordering. |
protected boolean |
isEmbeddedMapping(org.jpox.store.mapped.mapping.JavaTypeMapping mapping)
Check if the mapping correspond to a non pc object or embedded field |
abstract java.util.Iterator |
iterator(org.jpox.StateManager ownerSM)
Accessor for an iterator through the container elements. |
org.jpox.store.query.ResultObjectFactory |
newResultObjectFactory(org.jpox.StateManager sm,
org.jpox.store.mapped.expression.QueryExpression stmt,
boolean ignoreCache,
boolean useFetchPlan)
Method to generate a new result object factory from which to retrieve element objects. |
protected int |
populateElementDiscriminatorInStatement(org.jpox.ObjectManager om,
java.sql.PreparedStatement ps,
int jdbcPosition,
boolean includeSubclasses,
ElementContainerStore.ElementInfo info)
Convenience method to populate the passed PreparedStatement with the value from the element discriminator, optionally including all subclasses of the element type. |
protected int |
populateElementInStatement(org.jpox.ObjectManager om,
java.sql.PreparedStatement ps,
java.lang.Object element,
int jdbcPosition)
Convenience method to populate the passed PreparedStatement with the value for the element. |
protected int |
populateEmbeddedElementFieldsInStatement(org.jpox.StateManager sm,
java.lang.Object element,
java.sql.PreparedStatement ps,
int jdbcPosition,
JoinTable joinTable)
Convenience method to populate the passed PreparedStatement with the field values from the embedded element starting at the specified jdbc position. |
protected int |
populateOrderInStatement(org.jpox.ObjectManager om,
java.sql.PreparedStatement ps,
int idx,
int jdbcPosition)
Convenience method to populate the passed PreparedStatement with the value for the order index. |
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 |
populateRelationDiscriminatorInStatement(org.jpox.ObjectManager om,
java.sql.PreparedStatement ps,
int jdbcPosition)
Convenience method to populate the passed PreparedStatement with the value for the distinguisher value. |
protected void |
setOwnerMemberMetaData(org.jpox.metadata.AbstractMemberMetaData mmd)
Method to set the owner field/property MetaData and sets whether null elements/values are allowed. |
int |
size(org.jpox.StateManager sm)
Method to return the size of the container. |
protected boolean |
validateElementForReading(org.jpox.StateManager sm,
java.lang.Object element)
Method to check if an element is already persistent or is persistent but managed by a different persistence manager. |
protected boolean |
validateElementForWriting(org.jpox.StateManager sm,
java.lang.Object element,
org.jpox.store.FieldValues fieldValues)
Method to check if an element is already persistent, or is managed by a different Persistencemanager. |
protected boolean |
validateElementType(org.jpox.ClassLoaderResolver clr,
java.lang.Object element)
Method to validate an element against the accepted type. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean iterateUsingDiscriminator
protected ElementContainerStore.ElementInfo[] elementInfo
protected org.jpox.metadata.AbstractClassMetaData emd
protected org.jpox.store.mapped.DatastoreContainerObject containerTable
protected org.jpox.store.mapped.mapping.JavaTypeMapping elementMapping
protected java.lang.String elementType
protected boolean elementsAreEmbedded
protected boolean elementsAreSerialised
protected boolean elementIsPersistentInterface
protected org.jpox.store.mapped.mapping.JavaTypeMapping orderMapping
protected org.jpox.store.mapped.mapping.JavaTypeMapping relationDiscriminatorMapping
protected java.lang.String relationDiscriminatorValue
protected final org.jpox.store.mapped.DatastoreIdentifier elmIdentifier
protected org.jpox.ClassLoaderResolver clr
protected java.lang.String clearStmt
protected java.lang.String addStmt
protected java.lang.String removeStmt
protected boolean usingDiscriminatorInSizeStmt
protected static final org.jpox.util.Localiser LOCALISER
protected RDBMSManager storeMgr
protected org.jpox.store.mapped.DatastoreAdapter dba
protected org.jpox.store.mapped.mapping.JavaTypeMapping ownerMapping
protected org.jpox.metadata.AbstractMemberMetaData ownerMemberMetaData
protected boolean allowsNull
| Constructor Detail |
|---|
protected ElementContainerStore(org.jpox.store.StoreManager storeMgr,
org.jpox.ClassLoaderResolver clr)
storeMgr - Manager for the storeclr - ClassLoader resolver| Method Detail |
|---|
protected ElementContainerStore.ElementInfo[] getElementInformationForClass()
public boolean hasOrderMapping()
public java.lang.String getElementType()
protected boolean validateElementType(org.jpox.ClassLoaderResolver clr,
java.lang.Object element)
clr - The ClassLoaderResolverelement - The element to validate
protected boolean validateElementForReading(org.jpox.StateManager sm,
java.lang.Object element)
sm - The state manager of this ownerelement - The element
protected boolean validateElementForWriting(org.jpox.StateManager sm,
java.lang.Object element,
org.jpox.store.FieldValues fieldValues)
sm - The state manager of this ownerelement - The elementfieldValues - any initial field values to use if persisting the element
protected int populateElementInStatement(org.jpox.ObjectManager om,
java.sql.PreparedStatement ps,
java.lang.Object element,
int jdbcPosition)
om - Object Managerps - The PreparedStatementelement - The elementjdbcPosition - Position in JDBC statement to populate
protected int populateOrderInStatement(org.jpox.ObjectManager om,
java.sql.PreparedStatement ps,
int idx,
int jdbcPosition)
om - Object Managerps - The PreparedStatementidx - The order valuejdbcPosition - Position in JDBC statement to populate
protected int populateRelationDiscriminatorInStatement(org.jpox.ObjectManager om,
java.sql.PreparedStatement ps,
int jdbcPosition)
om - Object Managerps - The PreparedStatementjdbcPosition - Position in JDBC statement to populate
protected int populateElementDiscriminatorInStatement(org.jpox.ObjectManager om,
java.sql.PreparedStatement ps,
int jdbcPosition,
boolean includeSubclasses,
ElementContainerStore.ElementInfo info)
om - Persistence Managerps - The PreparedStatementjdbcPosition - Position in JDBC statement to populateincludeSubclasses - Whether to include subclassesinfo - The element information
protected int populateEmbeddedElementFieldsInStatement(org.jpox.StateManager sm,
java.lang.Object element,
java.sql.PreparedStatement ps,
int jdbcPosition,
JoinTable joinTable)
sm - State Manager of the owning containerelement - The embedded elementps - The PreparedStatementjdbcPosition - JDBC position in the statement to start atjoinTable - The Join table where the elements are embedded
protected java.lang.String getClearStmt()
DELETE FROM CONTAINERTABLE WHERE OWNERCOL = ? [AND RELATION_DISCRIM=?]TODO Add a discriminator restriction on this statement so we only clear ones with a valid discriminator value
public abstract java.util.Iterator iterator(org.jpox.StateManager ownerSM)
ownerSM - State Manager for the container.
public void clear(org.jpox.StateManager ownerSM)
ownerSM - State Manager for the container.protected java.lang.String getSizeStmt()
SELECT COUNT(*) FROM TBL THIS [INNER JOIN ELEM_TBL ELEM ON TBL.COL = ELEM.ID] - when no null [LEFT OUTER JOIN ELEM_TBL ELEM ON TBL.COL = ELEM.ID] - when allows null WHERE THIS.OWNERCOL=? [AND THIS.ORDERCOL IS NOT NULL] [AND (DISCRIMINATOR=? OR DISCRMINATOR=? OR DISCRIMINATOR=? [OR DISCRIMINATOR IS NULL])] [AND RELATION_DISCRIM=?]The discriminator part includes all subclasses of the element type. If the element is in a different table to the container then an INNER JOIN will be present to link the two tables, and table aliases will be present also. TODO Update this to allow for getting the size when more than 1 element table.
public int size(org.jpox.StateManager sm)
sm - The state manager.
protected java.lang.String getAddStmt()
INSERT INTO COLLTABLE (OWNERCOL,[ELEMENTCOL],[EMBEDDEDFIELD1, EMBEDDEDFIELD2,...],[ORDERCOL]) VALUES (?,?,?)
public org.jpox.store.query.ResultObjectFactory newResultObjectFactory(org.jpox.StateManager sm,
org.jpox.store.mapped.expression.QueryExpression stmt,
boolean ignoreCache,
boolean useFetchPlan)
sm - State Manager for ownerstmt - The queryignoreCache - Whether to ignore the cacheuseFetchPlan - Whether to use the current FetchPlan
protected void setOwnerMemberMetaData(org.jpox.metadata.AbstractMemberMetaData mmd)
mmd - MetaData for the field/property owning this backing store.public org.jpox.store.StoreManager getStoreManager()
public org.jpox.store.mapped.mapping.JavaTypeMapping getOwnerMapping()
protected boolean isEmbeddedMapping(org.jpox.store.mapped.mapping.JavaTypeMapping mapping)
mapping - the mapping
protected int populateOwnerInStatement(org.jpox.StateManager sm,
org.jpox.ObjectManager om,
java.sql.PreparedStatement ps,
int jdbcPosition)
sm - State Managerom - Object Managerps - The PreparedStatementjdbcPosition - Position in JDBC statement to populate
protected org.jpox.StateManager getStateManagerForEmbeddedPCObject(org.jpox.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
protected boolean allowsBatching()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||