|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jpox.store.rdbms.scostore.ElementContainerStore
org.jpox.store.rdbms.scostore.AbstractCollectionStore
org.jpox.store.rdbms.scostore.JoinSetStore
public class JoinSetStore
Representation of a Normal Set as part of a relationship. This class is used where you have a 1-N and the tables are joined via a link table. That is one table is the owner, and it has a link table to another table, with the link table having 2 columns - the ids of the 2 tables. This is in contrast to InverseSetStore which represents 1-N relationships without using a link table (using an id in the other table).
For sets of primitive types (eg Date,String etc), the NormalSetStore is used, but the 'link' table contains the id of the owner and the field(s) representing the primitive type.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.jpox.store.rdbms.scostore.ElementContainerStore |
---|
ElementContainerStore.ElementInfo |
Field Summary | |
---|---|
protected java.lang.String |
addStmt
|
protected DatastoreAdapter |
dba
Datastore adapter in use by this store. |
protected static Localiser |
LOCALISER
Localiser for messages. |
protected java.lang.String |
locateStmt
Statement to check the existence of an owner-element relation. |
protected boolean |
m2n
Whether this relation is one end of an M-N relation. |
protected java.lang.String |
maxOrderColumnIdStmt
Statement to get the maximum order column id so we can set the next insert value. |
protected AbstractPropertyMetaData |
ownerFieldMetaData
MetaData for the field in the owner with this container. |
protected JavaTypeMapping |
ownerMapping
Mapping to the owner of the container. |
protected java.lang.String |
removeStmt
|
protected java.lang.String |
setName
|
protected StoreManager |
storeMgr
Manager for the store. |
protected DatastoreIdentifier |
thisIdentifier
Identifier for the container in JDOQL queries. |
Fields inherited from class org.jpox.store.rdbms.scostore.AbstractCollectionStore |
---|
containsStmt |
Fields inherited from class org.jpox.store.rdbms.scostore.ElementContainerStore |
---|
clearStmt, clr, containerTable, elementInfo, elementMapping, elementsAreEmbedded, elementsAreSerialised, elementType, elmIdentifier, emd, iterateUsingDiscriminator, orderMapping, relationDiscriminatorMapping, relationDiscriminatorValue, sizeStmt |
Constructor Summary | |
---|---|
JoinSetStore(AbstractPropertyMetaData fmd,
CollectionTable joinTable,
ClassLoaderResolver clr)
Constructor for the relationship representation. |
Method Summary | |
---|---|
boolean |
add(StateManager sm,
java.lang.Object element)
Adds one element to the association owner vs elements. |
boolean |
addAll(StateManager sm,
java.util.Collection elements)
Adds all elements from a collection to the association container. |
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 QueryExpression |
getIteratorStatement(StateManager ownerSM)
Accessor for the statement for the iterator. |
JavaTypeMapping |
getOwnerMapping()
Accessor for the owner mapping. |
protected java.lang.String |
getRemoveAllStmt(StateManager ownerSm,
java.util.Collection elements)
Generate statement for removing a collection of items from the Set. |
protected java.lang.String |
getRemoveStmt()
Generate statement for deleting items from the Set. |
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 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 |
java.util.Iterator |
iterator(StateManager ownerSM)
Accessor for an iterator for the set. |
ScalarExpression |
joinElementsTo(QueryExpression stmt,
QueryExpression parentStmt,
JavaTypeMapping ownerMapping,
LogicSetExpression ownerTe,
DatastoreIdentifier setRangeVar,
java.lang.Class filteredElementType,
ScalarExpression elmExpr,
DatastoreIdentifier elementRangeVar)
Utility for use in building a query, joining the element table and the owner table. |
boolean |
locate(StateManager sm,
java.lang.Object element)
Method to check for the existence in the datastore of an owner-element relation. |
QueryExpression |
newQueryStatement(StateManager sm,
java.lang.String candidateClass)
Utility method to return a new QueryStatement for retrieval of the elements of this Set. |
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. |
boolean |
remove(StateManager sm,
java.lang.Object element)
Removes the association to one element |
boolean |
removeAll(StateManager sm,
java.util.Collection elements)
Remove all elements from a collection from the association owner vs elements. |
Methods inherited from class org.jpox.store.rdbms.scostore.AbstractCollectionStore |
---|
contains, getContainsStmt, getExistsSubquery, getSizeSubquery, getUpdateEmbeddedElementStmt, updateEmbeddedElement |
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.CollectionStore |
---|
clear, contains, getElementType, getExistsSubquery, getSizeSubquery, hasOrderMapping, newResultObjectFactory, size, updateEmbeddedElement |
Methods inherited from interface org.jpox.store.scostore.Store |
---|
getOwnerMapping, getStoreManager |
Field Detail |
---|
protected final java.lang.String locateStmt
protected final java.lang.String maxOrderColumnIdStmt
protected final boolean m2n
protected java.lang.String setName
protected java.lang.String addStmt
protected java.lang.String removeStmt
protected static final Localiser LOCALISER
protected StoreManager storeMgr
protected DatastoreAdapter dba
protected JavaTypeMapping ownerMapping
protected AbstractPropertyMetaData ownerFieldMetaData
protected final DatastoreIdentifier thisIdentifier
Constructor Detail |
---|
public JoinSetStore(AbstractPropertyMetaData fmd, CollectionTable joinTable, ClassLoaderResolver clr)
joinTable
- The table for the linkclr
- The ClassLoaderResolverMethod Detail |
---|
protected java.lang.String getRemoveStmt()
DELETE FROM SETTABLE WHERE OWNERCOL=? AND ELEMENTCOL = ? [AND EMBEDDEDFIELD1 = ? AND EMBEDDEDFIELD2 = ? AND EMBEDDEDFIELD3 = ?] [AND RELATION_DISCRIM = ?]
protected java.lang.String getRemoveAllStmt(StateManager ownerSm, java.util.Collection elements)
DELETE FROM SETTABLE WHERE (OWNERCOL=? AND ELEMENTCOL=?) OR (OWNERCOL=? AND ELEMENTCOL=?) OR (OWNERCOL=? AND ELEMENTCOL=?)
ownerSm
- The owner StateManagerelements
- Collection of elements to remove
public boolean removeAll(StateManager sm, java.util.Collection elements)
removeAll
in interface CollectionStore
sm
- State Manager for the containerelements
- Collection of elements to remove
public boolean locate(StateManager sm, java.lang.Object element)
sm
- State Manager for the ownerelement
- The element
public boolean add(StateManager sm, java.lang.Object element)
add
in interface CollectionStore
sm
- State Manager for the container.element
- Element to add
public boolean addAll(StateManager sm, java.util.Collection elements)
addAll
in interface CollectionStore
sm
- State Manager for the container.elements
- Collection of elements to add
protected QueryExpression getIteratorStatement(StateManager ownerSM)
ownerSM
- the owner StateManager
public QueryExpression newQueryStatement(StateManager sm, java.lang.String candidateClass)
sm
- StateManager for this objectcandidateClass
- Class for the element end of the link.
public ScalarExpression joinElementsTo(QueryExpression stmt, QueryExpression parentStmt, JavaTypeMapping ownerMapping, LogicSetExpression ownerTe, DatastoreIdentifier setRangeVar, java.lang.Class filteredElementType, ScalarExpression elmExpr, DatastoreIdentifier elementRangeVar)
stmt
- The Query StatementparentStmt
- the parent Query Statement. If there is no parent, parentStmt
must be equals to stmt
ownerMapping
- the mapping for the owner.ownerTe
- Table Expression for the ownersetRangeVar
- The range variable for the "Set" table.filteredElementType
- The Class Type for the filtered elementelmExpr
- The Expression for the elementelementRangeVar
- The SQL alias, or "range variable", to assign to the
expression or to the element table.
protected void initialiseStatements()
initialiseStatements
in class AbstractCollectionStore
public java.util.Iterator iterator(StateManager ownerSM)
iterator
in interface CollectionStore
iterator
in class ElementContainerStore
ownerSM
- State Manager for the set.
public boolean remove(StateManager sm, java.lang.Object element)
remove
in interface CollectionStore
sm
- State Manager for the containerelement
- Element to remove
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 |