|
||||||||||
| 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 boolean |
allowsNull
Whether the container allows null elements/values. |
protected org.jpox.store.mapped.DatastoreAdapter |
dba
Datastore adapter in use by this store. |
protected static org.jpox.util.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 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 java.lang.String |
setName
|
protected RDBMSManager |
storeMgr
Manager for the store. |
| Fields inherited from class org.jpox.store.rdbms.scostore.AbstractCollectionStore |
|---|
containsStmt |
| Fields inherited from class org.jpox.store.rdbms.scostore.ElementContainerStore |
|---|
addStmt, clearStmt, clr, containerTable, elementInfo, elementIsPersistentInterface, elementMapping, elementsAreEmbedded, elementsAreSerialised, elementType, elmIdentifier, emd, iterateUsingDiscriminator, orderMapping, relationDiscriminatorMapping, relationDiscriminatorValue, removeStmt, usingDiscriminatorInSizeStmt |
| Constructor Summary | |
|---|---|
JoinSetStore(org.jpox.metadata.AbstractMemberMetaData fmd,
CollectionTable joinTable,
org.jpox.ClassLoaderResolver clr)
Constructor for the relationship representation. |
|
| Method Summary | |
|---|---|
boolean |
add(org.jpox.StateManager sm,
java.lang.Object element,
int size)
Adds one element to the association owner vs elements. |
boolean |
addAll(org.jpox.StateManager sm,
java.util.Collection elements,
int size)
Adds all elements from a collection to the association container. |
protected boolean |
allowsBatching()
Convenience method to return if the RDBMS supports batching and the user wants batching. |
protected org.jpox.store.mapped.expression.QueryExpression |
getIteratorStatement(org.jpox.StateManager ownerSM)
Accessor for the statement for the iterator. |
org.jpox.store.mapped.mapping.JavaTypeMapping |
getOwnerMapping()
Accessor for the owner mapping. |
protected java.lang.String |
getRemoveAllStmt(org.jpox.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 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. |
protected int[] |
internalAdd(org.jpox.StateManager ownerSM,
org.jpox.ManagedConnection conn,
boolean batched,
java.lang.Object element,
boolean processNow)
Method to process an "add" statement. |
protected int[] |
internalRemove(org.jpox.StateManager ownerSM,
org.jpox.ManagedConnection conn,
boolean batched,
java.lang.Object element,
boolean executeNow)
Method to process a "remove" statement. |
protected boolean |
isEmbeddedMapping(org.jpox.store.mapped.mapping.JavaTypeMapping mapping)
Check if the mapping correspond to a non pc object or embedded field |
java.util.Iterator |
iterator(org.jpox.StateManager ownerSM)
Accessor for an iterator for the set. |
org.jpox.store.mapped.expression.ScalarExpression |
joinElementsTo(org.jpox.store.mapped.expression.QueryExpression stmt,
org.jpox.store.mapped.expression.QueryExpression parentStmt,
org.jpox.store.mapped.mapping.JavaTypeMapping ownerMapping,
org.jpox.store.mapped.expression.LogicSetExpression ownerTblExpr,
org.jpox.store.mapped.DatastoreIdentifier setTableAlias,
java.lang.Class filteredElementType,
org.jpox.store.mapped.expression.ScalarExpression elementExpr,
org.jpox.store.mapped.DatastoreIdentifier elementTableAlias,
boolean existsQuery)
Utility for use in building a query, joining the element table and the owner table. |
boolean |
locate(org.jpox.StateManager sm,
java.lang.Object element)
Method to check for the existence in the datastore of an owner-element relation. |
org.jpox.store.mapped.expression.QueryExpression |
newQueryStatement(org.jpox.StateManager sm,
java.lang.String candidateClass,
org.jpox.store.mapped.DatastoreIdentifier candidateAlias)
Utility method to return a new QueryStatement for retrieval of the elements of this Set. |
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. |
boolean |
remove(org.jpox.StateManager sm,
java.lang.Object element,
int size,
boolean allowDependentField)
Removes the association to one element |
boolean |
removeAll(org.jpox.StateManager sm,
java.util.Collection elements,
int size)
Remove all elements from a collection from the association owner vs elements. |
protected void |
setOwnerMemberMetaData(org.jpox.metadata.AbstractMemberMetaData mmd)
Method to set the owner field/property MetaData and sets whether null elements/values are allowed. |
| 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, hasOrderMapping, size, updateEmbeddedElement |
| Methods inherited from interface org.jpox.store.scostore.Store |
|---|
getStoreManager |
| Methods inherited from interface org.jpox.store.mapped.scostore.CollectionStoreQueryable |
|---|
newResultObjectFactory |
| Field Detail |
|---|
protected java.lang.String locateStmt
protected java.lang.String maxOrderColumnIdStmt
protected final boolean m2n
protected java.lang.String setName
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 |
|---|
public JoinSetStore(org.jpox.metadata.AbstractMemberMetaData fmd,
CollectionTable joinTable,
org.jpox.ClassLoaderResolver clr)
joinTable - The table for the linkclr - The ClassLoaderResolver| Method Detail |
|---|
protected java.lang.String getRemoveStmt()
DELETE FROM SETTABLE WHERE OWNERCOL=? AND ELEMENTCOL = ? [AND EMBEDDEDFIELD1 = ? AND EMBEDDEDFIELD2 = ? AND EMBEDDEDFIELD3 = ?] [AND RELATION_DISCRIM = ?]
getRemoveStmt in class AbstractCollectionStore
protected java.lang.String getRemoveAllStmt(org.jpox.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(org.jpox.StateManager sm,
java.util.Collection elements,
int size)
removeAll in interface org.jpox.store.scostore.CollectionStoresm - State Manager for the containerelements - Collection of elements to remove
public boolean locate(org.jpox.StateManager sm,
java.lang.Object element)
sm - State Manager for the ownerelement - The element
public boolean add(org.jpox.StateManager sm,
java.lang.Object element,
int size)
add in interface org.jpox.store.scostore.CollectionStoresm - State Manager for the container.element - Element to add
public boolean addAll(org.jpox.StateManager sm,
java.util.Collection elements,
int size)
addAll in interface org.jpox.store.scostore.CollectionStoresm - State Manager for the container.elements - Collection of elements to addsize - Current size of set (if known). Not used by sets
protected org.jpox.store.mapped.expression.QueryExpression getIteratorStatement(org.jpox.StateManager ownerSM)
ownerSM - the owner StateManager
public org.jpox.store.mapped.expression.QueryExpression newQueryStatement(org.jpox.StateManager sm,
java.lang.String candidateClass,
org.jpox.store.mapped.DatastoreIdentifier candidateAlias)
sm - StateManager for this objectcandidateClass - Class for the element end of the link.candidateAlias - Alias for the candidate
public org.jpox.store.mapped.expression.ScalarExpression joinElementsTo(org.jpox.store.mapped.expression.QueryExpression stmt,
org.jpox.store.mapped.expression.QueryExpression parentStmt,
org.jpox.store.mapped.mapping.JavaTypeMapping ownerMapping,
org.jpox.store.mapped.expression.LogicSetExpression ownerTblExpr,
org.jpox.store.mapped.DatastoreIdentifier setTableAlias,
java.lang.Class filteredElementType,
org.jpox.store.mapped.expression.ScalarExpression elementExpr,
org.jpox.store.mapped.DatastoreIdentifier elementTableAlias,
boolean existsQuery)
stmt - The Query StatementparentStmt - the parent Query Statement. If no parent, "parentStmt" must be equal to "stmt"ownerMapping - the mapping for the ownerownerTblExpr - Table Expression for the ownerfilteredElementType - The Class Type for the filtered elementelementExpr - The Expression for the elementelementTableAlias - The SQL alias to assign to the element table expressionsetTableAlias - The alias for the "Set" tableexistsQuery - Whether this is joining for an EXISTS query
public java.util.Iterator iterator(org.jpox.StateManager ownerSM)
iterator in interface org.jpox.store.scostore.CollectionStoreiterator in class ElementContainerStoreownerSM - State Manager for the set.
protected int[] internalAdd(org.jpox.StateManager ownerSM,
org.jpox.ManagedConnection conn,
boolean batched,
java.lang.Object element,
boolean processNow)
throws java.sql.SQLException
ownerSM - StateManager for the ownerconn - The connectionbatched - Whether we are batching itelement - The element
java.sql.SQLException - Thrown if an error occurs
public boolean remove(org.jpox.StateManager sm,
java.lang.Object element,
int size,
boolean allowDependentField)
remove in interface org.jpox.store.scostore.CollectionStoresm - State Manager for the containerelement - Element to removesize - Current sizeallowDependentField - Whether to allow any cascade deletes caused by this removal
protected int[] internalRemove(org.jpox.StateManager ownerSM,
org.jpox.ManagedConnection conn,
boolean batched,
java.lang.Object element,
boolean executeNow)
throws java.sql.SQLException
internalRemove in class AbstractCollectionStoreownerSM - StateManager for the ownerconn - The connectionbatched - Whether we are batching itelement - The elementexecuteNow - Whether to execute the statement rather than allow batching til later
java.sql.SQLException - Thrown if an error occursprotected 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 | |||||||||