|
||||||||||
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.FKSetStore
public class FKSetStore
Representation of an Inverse Set as part of a relationship. This class is used where you have a 1-N and the tables are not joined via a link table. That is there is an owner table, and a collection table, and the collection table has a column being the id of the owner table. This is in contrast to NormalSetStore which represents 1-N relationships using a link table. There are 2 possible uses here
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 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 | |
---|---|
FKSetStore(AbstractPropertyMetaData fmd,
RDBMSManager storeMgr,
ClassLoaderResolver clr)
Constructor for the relationship representation. |
Method Summary | |
---|---|
boolean |
add(StateManager sm,
java.lang.Object element)
Method to add an object to the relationship at the collection end. |
boolean |
addAll(StateManager sm,
java.util.Collection elements)
Method to add a collection of object to the relationship at the collection end. |
void |
clear(StateManager ownerSM)
Method to allow the Set relationship to be cleared out. |
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 |
getClearNullifyStmt()
Generates the statement for clearing items by nulling the owner link out. |
protected java.lang.String |
getContainsStmt()
Generate statement for retrieving the contents of the Collection. |
protected QueryExpression |
getIteratorStatement(StateManager ownerSM)
Accessor for a QueryStatement to retrieve the elements of the set. |
protected int |
getOwnerFieldOwner(StateManager sm)
|
JavaTypeMapping |
getOwnerMapping()
Accessor for the owner mapping. |
protected java.lang.String |
getRemoveStmt()
Generate statement for deleting an item from the Set. |
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. |
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. |
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)
Method to remove the link to the collection object specified. |
boolean |
removeAll(StateManager sm,
java.util.Collection elements)
Method to remove the links to a collection of elements specified. |
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. |
Methods inherited from class org.jpox.store.rdbms.scostore.AbstractCollectionStore |
---|
contains, getExistsSubquery, getSizeSubquery, getUpdateEmbeddedElementStmt, updateEmbeddedElement |
Methods inherited from class org.jpox.store.rdbms.scostore.ElementContainerStore |
---|
getAddStmt, getClearStmt, getElementInformationForClass, getElementType, hasOrderMapping, newResultObjectFactory, populateElementDiscriminatorInStatement, populateElementInStatement, populateEmbeddedElementFieldsInStatement, populateOrderInStatement, populateRelationDiscriminatorInStatement, size, validateElementForReading, validateElementType |
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 |
---|
contains, getElementType, getExistsSubquery, getSizeSubquery, hasOrderMapping, newResultObjectFactory, size, updateEmbeddedElement |
Methods inherited from interface org.jpox.store.scostore.Store |
---|
getOwnerMapping, getStoreManager |
Field Detail |
---|
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 FKSetStore(AbstractPropertyMetaData fmd, RDBMSManager storeMgr, ClassLoaderResolver clr)
fmd
- The MetaData for the field that this representsstoreMgr
- The RDBMSManager managing the associated datastore.clr
- The ClassLoaderResolverMethod Detail |
---|
protected java.lang.String getSizeStmt()
SELECT COUNT(*) FROM CONTAINERTABLE WHERE OWNERCOL=? [AND ORDERCOL IS NOT NULL] [AND (DISCRIMINATOR=? OR DISCRMINATOR=? OR DISCRIMINATOR=?)]The discriminator part includes all subclasses of the element type
getSizeStmt
in class ElementContainerStore
protected java.lang.String getContainsStmt()
SELECT OWNERCOL FROM COLLECTIONTABLE WHERE OWNERCOL=? AND ELEMENTCOL = ? [AND DISCRIMINATOR = ?]
getContainsStmt
in class AbstractCollectionStore
protected java.lang.String getClearNullifyStmt()
UPDATE LISTTABLE SET OWNERCOL=NULL [,DISTINGUISHER=NULL] WHERE OWNERCOL=?when there is only one element table, and will be
UPDATE ? SET OWNERCOL=NULL [,DISTINGUISHER=NULL] WHERE OWNERCOL=?when there is more than 1 element table.
protected void validateElementForWriting(StateManager sm, java.lang.Object element)
validateElementForWriting
in class ElementContainerStore
sm
- The state manager of this collectionelement
- The elementprotected int getOwnerFieldOwner(StateManager sm)
public boolean add(StateManager sm, java.lang.Object element)
add
in interface CollectionStore
sm
- StateManager of the owner of the Setelement
- Element to be added
public boolean addAll(StateManager sm, java.util.Collection elements)
addAll
in interface CollectionStore
sm
- StateManager of the Setelements
- Elements to be added
public boolean remove(StateManager sm, java.lang.Object element)
remove
in interface CollectionStore
sm
- The StateManager of the Setelement
- The element of the collection to be deleted.
public boolean removeAll(StateManager sm, java.util.Collection elements)
removeAll
in interface CollectionStore
sm
- The StateManager of the Setelements
- The elements of the collection to be deleted.
public void clear(StateManager ownerSM)
clear
in interface CollectionStore
clear
in class ElementContainerStore
ownerSM
- StateManager of the Setprotected 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.
protected java.lang.String getRemoveStmt()
DELETE FROM SETTABLE WHERE OWNERCOL=? AND ELEMENTCOL = ? [AND DISCRIM = ?]
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 |