|
|||||||||||
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.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 |
clearStmt
Statement for clearing the container. |
protected ClassLoaderResolver |
clr
ClassLoader resolver. |
protected DatastoreContainerObject |
containerTable
Table containing the link between owner and element. |
protected DatastoreAdapter |
dba
Datastore adapter in use by this store. |
protected ElementContainerStore.ElementInfo[] |
elementInfo
Information for the elements of this container. |
protected 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 DatastoreIdentifier |
elmIdentifier
Identifier for elements in JDOQL queries. |
protected 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 Localiser |
LOCALISER
Localiser for messages. |
protected JavaTypeMapping |
orderMapping
Mapping for an ordering column to allow for duplicates in the container. |
protected AbstractPropertyMetaData |
ownerFieldMetaData
MetaData for the field in the owner with this container. |
protected JavaTypeMapping |
ownerMapping
Mapping to the owner of the container. |
protected 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 |
sizeStmt
Statement for getting the size of the container. |
protected StoreManager |
storeMgr
Manager for the store. |
protected DatastoreIdentifier |
thisIdentifier
Identifier for the container in JDOQL queries. |
Constructor Summary | |
protected |
ElementContainerStore(StoreManager storeMgr,
ClassLoaderResolver clr)
Constructor. |
Method Summary | |
void |
clear(StateManager ownerSM)
Clear the association from owner to all elements |
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. |
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. |
JavaTypeMapping |
getOwnerMapping()
Accessor for the owner mapping. |
protected java.lang.String |
getSizeStmt()
Generate statement for getting the size of the container. |
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. |
boolean |
hasOrderMapping()
Accessor for whether the store has an order mapping, to allow for duplicates or ordering. |
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 |
abstract java.util.Iterator |
iterator(StateManager ownerSM)
Accessor for an iterator through the container elements. |
Query.ResultObjectFactory |
newResultObjectFactory(StateManager sm,
QueryExpression stmt,
boolean ignoreCache,
boolean useFetchPlan)
Method to generate a new result object factory from which to retrieve element objects. |
protected int |
populateElementDiscriminatorInStatement(PersistenceManager pm,
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(PersistenceManager pm,
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(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(PersistenceManager pm,
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(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 |
populateRelationDiscriminatorInStatement(PersistenceManager pm,
java.sql.PreparedStatement ps,
int jdbcPosition)
Convenience method to populate the passed PreparedStatement with the value for the distinguisher value. |
int |
size(StateManager sm)
Method to return the size of the container. |
protected boolean |
validateElementForReading(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 void |
validateElementForWriting(StateManager sm,
java.lang.Object element)
Method to check if an element is already persistent, or is managed by a different Persistencemanager. |
protected boolean |
validateElementType(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 AbstractClassMetaData emd
protected DatastoreContainerObject containerTable
protected JavaTypeMapping elementMapping
protected java.lang.String elementType
protected boolean elementsAreEmbedded
protected boolean elementsAreSerialised
protected JavaTypeMapping orderMapping
protected JavaTypeMapping relationDiscriminatorMapping
protected java.lang.String relationDiscriminatorValue
protected final DatastoreIdentifier elmIdentifier
protected ClassLoaderResolver clr
protected java.lang.String sizeStmt
protected java.lang.String clearStmt
protected static final Localiser LOCALISER
protected StoreManager storeMgr
protected DatastoreAdapter dba
protected JavaTypeMapping ownerMapping
protected AbstractPropertyMetaData ownerFieldMetaData
protected final DatastoreIdentifier thisIdentifier
Constructor Detail |
protected ElementContainerStore(StoreManager storeMgr, ClassLoaderResolver clr)
storeMgr
- Manager for the storeclr
- ClassLoader resolverMethod Detail |
protected void initialiseStatements()
protected ElementContainerStore.ElementInfo[] getElementInformationForClass()
public boolean hasOrderMapping()
public java.lang.String getElementType()
protected boolean validateElementType(ClassLoaderResolver clr, java.lang.Object element)
clr
- The ClassLoaderResolverelement
- The element to validate
protected boolean validateElementForReading(StateManager sm, java.lang.Object element)
sm
- The state manager of this ownerelement
- The element
protected void validateElementForWriting(StateManager sm, java.lang.Object element)
sm
- The state manager of this ownerelement
- The elementprotected int populateElementInStatement(PersistenceManager pm, java.sql.PreparedStatement ps, java.lang.Object element, int jdbcPosition)
pm
- Persistence Managerps
- The PreparedStatementelement
- The elementjdbcPosition
- Position in JDBC statement to populate
protected int populateOrderInStatement(PersistenceManager pm, java.sql.PreparedStatement ps, int idx, int jdbcPosition)
pm
- Persistence Managerps
- The PreparedStatementidx
- The order valuejdbcPosition
- Position in JDBC statement to populate
protected int populateRelationDiscriminatorInStatement(PersistenceManager pm, java.sql.PreparedStatement ps, int jdbcPosition)
pm
- Persistence Managerps
- The PreparedStatementjdbcPosition
- Position in JDBC statement to populate
protected int populateElementDiscriminatorInStatement(PersistenceManager pm, java.sql.PreparedStatement ps, int jdbcPosition, boolean includeSubclasses, ElementContainerStore.ElementInfo info)
pm
- Persistence Managerps
- The PreparedStatementjdbcPosition
- Position in JDBC statement to populateincludeSubclasses
- Whether to include subclassesinfo
- The element information
protected int populateEmbeddedElementFieldsInStatement(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(StateManager ownerSM)
ownerSM
- State Manager for the container.
public void clear(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] WHERE THIS.OWNERCOL=? [AND THIS.ORDERCOL IS NOT NULL] [AND (DISCRIMINATOR=? OR DISCRMINATOR=? OR DISCRIMINATOR=?)] [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(StateManager sm)
sm
- The state manager.
protected java.lang.String getAddStmt()
INSERT INTO LISTTABLE (OWNERCOL,[ELEMENTCOL],[EMBEDDEDFIELD1, EMBEDDEDFIELD2,...],[ORDERCOL]) VALUES (?,?,?)
public Query.ResultObjectFactory newResultObjectFactory(StateManager sm, QueryExpression stmt, boolean ignoreCache, boolean useFetchPlan)
sm
- State Manager for ownerstmt
- The queryignoreCache
- Whether to ignore the cacheuseFetchPlan
- Whether to use the current FetchPlan
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 |