|
||||||||||
| 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.JoinListStore
public class JoinListStore
Representation of the backing store for a join-table List. Uses a Join table, so we use 3 tables - owner table, join table and element table.
| 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 boolean |
indexedList
Whether the list is indexed (like with JDO). |
protected java.lang.String |
indexOfStmt
|
protected java.lang.String |
lastIndexOfStmt
|
protected java.lang.String |
listName
|
protected static org.jpox.util.Localiser |
LOCALISER
Localiser for messages. |
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 |
removeAtStmt
|
protected java.lang.String |
setStmt
|
protected java.lang.String |
shiftStmt
|
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 | |
|---|---|
JoinListStore(org.jpox.metadata.AbstractMemberMetaData fmd,
CollectionTable joinTable,
org.jpox.ClassLoaderResolver clr)
Constructor. |
|
| Method Summary | |
|---|---|
boolean |
add(org.jpox.StateManager sm,
java.lang.Object element,
int size)
Method to add an element to the List. |
void |
add(org.jpox.StateManager sm,
java.lang.Object element,
int index,
int size)
Method to add an element to the List. |
boolean |
addAll(org.jpox.StateManager sm,
java.util.Collection elements,
int size)
Method to add a collection of elements to the List. |
boolean |
addAll(org.jpox.StateManager sm,
java.util.Collection elements,
int index,
int size)
Method to add all elements from a Collection to the List. |
protected boolean |
allowsBatching()
Convenience method to return if the RDBMS supports batching and the user wants batching. |
java.lang.Object |
get(org.jpox.StateManager sm,
int index)
Method to retrieve an element from the List. |
protected java.lang.String |
getIndexOfStmt()
Generate statement for getting the index of an item. |
protected int[] |
getIndicesOf(org.jpox.StateManager sm,
java.util.Collection elements)
Utility to find the indices of a collection of elements. |
protected java.lang.String |
getIndicesOfStmt(java.util.Collection elements)
Generates the statement for getting the indices of a collection of element. |
protected org.jpox.store.mapped.expression.QueryExpression |
getIteratorStatement(org.jpox.StateManager ownerSM,
int start_index,
int end_index)
Accessor for the iterator statement to retrieve element(s) in a range from the List. |
protected java.lang.String |
getLastIndexOfStmt()
Generates the statement for getting the index of the last item. |
org.jpox.store.mapped.mapping.JavaTypeMapping |
getOwnerMapping()
Accessor for the owner mapping. |
protected java.lang.String |
getRemoveAllStmt(java.util.Collection elements)
Generate statement for removing a collection of items from the List. |
protected java.lang.String |
getRemoveAtStmt()
Generates the statement for removing an item. |
protected java.lang.String |
getSetStmt()
Generates the statement for setting an item. |
protected java.lang.String |
getShiftStmt()
Generates the statement for shifting items. |
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. |
int |
indexOf(org.jpox.StateManager sm,
java.lang.Object element)
Accessor for the indexOf an object in the List. |
protected boolean |
internalAdd(org.jpox.StateManager sm,
int start,
boolean atEnd,
java.util.Collection c,
int size)
Internal method to add element(s) to the List. |
protected java.util.List |
internalGetRange(org.jpox.StateManager sm,
int start,
int end)
Utility to retrieve (as a List) the elements for the List in a range depending on the specified start/end positions. |
protected boolean |
internalRemove(org.jpox.StateManager ownerSM,
java.lang.Object element,
int size)
Convenience method to remove the specified element from the List. |
protected void |
internalRemoveAt(org.jpox.StateManager sm,
int index,
java.lang.String stmt,
int size)
Internal method to remove an object at a location in the List. |
protected int[] |
internalShift(org.jpox.StateManager ownerSM,
org.jpox.ManagedConnection conn,
boolean batched,
int oldIndex,
int amount,
boolean executeNow)
Method to process a "shift" statement, updating the index in the list of the specified index. |
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 sm)
Accessor for an iterator through the list elements. |
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 listTableAlias,
java.lang.Class filteredElementType,
org.jpox.store.mapped.expression.ScalarExpression elementExpr,
org.jpox.store.mapped.DatastoreIdentifier elementTableAlias,
boolean existsQuery)
Method used in queries when contains() has been invoked to join the collection table to the element table. |
int |
lastIndexOf(org.jpox.StateManager sm,
java.lang.Object element)
Method to retrieve the last index of an object in the list. |
java.util.ListIterator |
listIterator(org.jpox.StateManager sm)
Accessor for an iterator through the list elements. |
java.util.ListIterator |
listIterator(org.jpox.StateManager ownerSM,
int start)
Accessor for an iterator through the list elements. |
org.jpox.store.mapped.expression.QueryExpression |
newQueryStatement(org.jpox.StateManager sm,
java.lang.String candidateClass,
org.jpox.store.mapped.DatastoreIdentifier candidateAlias)
Utility to return a new QueryStatement. |
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 void |
prepareIndicesOfStmt(org.jpox.StateManager sm,
java.sql.PreparedStatement ps,
java.util.Collection elements)
Method to prepare the indicesOf statement for use. |
java.lang.Object |
remove(org.jpox.StateManager sm,
int index,
int size)
Method to remove an object at an index in the List. |
boolean |
remove(org.jpox.StateManager sm,
java.lang.Object element,
int size,
boolean allowDependentField)
Method to remove the specified element from the List. |
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 |
removeAt(org.jpox.StateManager sm,
int index,
int size)
Method to remove an element from the specified position |
java.lang.Object |
set(org.jpox.StateManager sm,
int index,
java.lang.Object element,
boolean allowDependentField)
Method to set an object in the List. |
protected void |
setOwnerMemberMetaData(org.jpox.metadata.AbstractMemberMetaData mmd)
Method to set the owner field/property MetaData and sets whether null elements/values are allowed. |
java.util.List |
subList(org.jpox.StateManager sm,
int start,
int end)
Method to retrieve a list of elements in a range. |
| Methods inherited from class org.jpox.store.rdbms.scostore.AbstractCollectionStore |
|---|
contains, getContainsStmt, getExistsSubquery, getRemoveStmt, getSizeSubquery, getUpdateEmbeddedElementStmt, internalRemove, 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 listName
protected java.lang.String removeAtStmt
protected java.lang.String setStmt
protected java.lang.String shiftStmt
protected java.lang.String indexOfStmt
protected java.lang.String lastIndexOfStmt
protected boolean indexedList
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 JoinListStore(org.jpox.metadata.AbstractMemberMetaData fmd,
CollectionTable joinTable,
org.jpox.ClassLoaderResolver clr)
joinTable - The join tableclr - ClassLoader resolver| Method Detail |
|---|
protected boolean internalAdd(org.jpox.StateManager sm,
int start,
boolean atEnd,
java.util.Collection c,
int size)
sm - The state managerstart - The start location (if required)atEnd - Whether to add the element at the endc - The collection of objects to add.size - Current size of list if known. -1 if not known
public java.lang.Object set(org.jpox.StateManager sm,
int index,
java.lang.Object element,
boolean allowDependentField)
sm - The state managerindex - The item indexelement - What to set it to.allowDependentField - Whether to allow dependent field deletes
protected java.lang.String getSetStmt()
UPDATE LISTTABLE SET [ELEMENTCOL = ?] [EMBEDDEDFIELD1=?, EMBEDDEDFIELD2=?, ...] WHERE OWNERCOL = ? AND INDEXCOL = ? [AND DISTINGUISHER=?]
protected boolean internalRemove(org.jpox.StateManager ownerSM,
java.lang.Object element,
int size)
element - The elementownerSM - StateManager of the ownersize - Current size of list if known. -1 if not known
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
protected void removeAt(org.jpox.StateManager sm,
int index,
int size)
sm - The State Manager for the listindex - The index of the elementsize - Current size of list (if known). -1 if not knownprotected java.lang.String getRemoveAllStmt(java.util.Collection elements)
DELETE FROM LISTTABLE
WHERE (OWNERCOL=? AND ELEMENTCOL=?) OR
(OWNERCOL=? AND ELEMENTCOL=?) OR
(OWNERCOL=? AND ELEMENTCOL=?)
elements - Collection of elements to remove
protected org.jpox.store.mapped.expression.QueryExpression getIteratorStatement(org.jpox.StateManager ownerSM,
int start_index,
int end_index)
ownerSM - The StateManagerstart_index - The start position in the List.end_index - The end position in the List.
public org.jpox.store.mapped.expression.QueryExpression newQueryStatement(org.jpox.StateManager sm,
java.lang.String candidateClass,
org.jpox.store.mapped.DatastoreIdentifier candidateAlias)
sm - The state managercandidateClass - The base classcandidateAlias - 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 listTableAlias,
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 - Expression for the elementelementTableAlias - The SQL alias to assign to the element table expressionlistTableAlias - The alias for the "List" table.existsQuery - Whether this is joining for an EXISTS query
public java.util.Iterator iterator(org.jpox.StateManager sm)
iterator in interface org.jpox.store.scostore.CollectionStoreiterator in class ElementContainerStoresm - State Manager for the container.
public java.util.ListIterator listIterator(org.jpox.StateManager sm)
listIterator in interface org.jpox.store.scostore.ListStoresm - State Manager for the container.
public java.util.ListIterator listIterator(org.jpox.StateManager ownerSM,
int start)
listIterator in interface org.jpox.store.scostore.ListStoreownerSM - State Manager for the container.start - The start point in the list.
public boolean add(org.jpox.StateManager sm,
java.lang.Object element,
int size)
add in interface org.jpox.store.scostore.CollectionStoresm - The state managerelement - The element to removesize - Size of the current list (if known, -1 if not)
public void add(org.jpox.StateManager sm,
java.lang.Object element,
int index,
int size)
add in interface org.jpox.store.scostore.ListStoreelement - The element to add.index - The location to add atsm - The state manager.
public boolean addAll(org.jpox.StateManager sm,
java.util.Collection elements,
int size)
addAll in interface org.jpox.store.scostore.CollectionStoresm - The state managerelements - The elements to removesize - Current size of the list (if known). -1 if not known
public boolean addAll(org.jpox.StateManager sm,
java.util.Collection elements,
int index,
int size)
addAll in interface org.jpox.store.scostore.ListStoresm - The state managerelements - The collectionindex - The location to add atsize - Current size of the list (if known). -1 if not known
public java.lang.Object get(org.jpox.StateManager sm,
int index)
get in interface org.jpox.store.scostore.ListStoresm - The state managerindex - The location of the element.
public int indexOf(org.jpox.StateManager sm,
java.lang.Object element)
indexOf in interface org.jpox.store.scostore.ListStoresm - The state managerelement - The element.
public int lastIndexOf(org.jpox.StateManager sm,
java.lang.Object element)
lastIndexOf in interface org.jpox.store.scostore.ListStoresm - The state manager.element - The object
public boolean remove(org.jpox.StateManager sm,
java.lang.Object element,
int size,
boolean allowDependentField)
remove in interface org.jpox.store.scostore.CollectionStoresm - The state managerelement - The element to remove.size - Current size of list if known. -1 if not knownallowDependentField - Whether to allow any cascade deletes caused by this removal
public java.lang.Object remove(org.jpox.StateManager sm,
int index,
int size)
remove in interface org.jpox.store.scostore.ListStoreindex - The locationsm - The state managersize - Current size of the list (if known). -1 if not known
public java.util.List subList(org.jpox.StateManager sm,
int start,
int end)
subList in interface org.jpox.store.scostore.ListStoresm - The state manager.start - From index (inclusive)end - To index (exclusive)
protected java.lang.String getIndexOfStmt()
SELECT INDEXCOL FROM LISTTABLE WHERE OWNERCOL=? AND ELEMENTCOL=? [AND EMBEDDEDFIELD1=? AND EMBEDDEDFIELD2=? AND ...] [AND DISTINGUISHER=?] ORDER BY INDEXCOL
protected java.lang.String getLastIndexOfStmt()
SELECT INDEXCOL FROM LISTTABLE WHERE OWNERCOL=? AND ELEMENTCOL=? [AND EMBEDDEDFIELD1=? AND EMBEDDEDFIELD2=? AND ...] [AND DISTINGUISHER=?] ORDER BY INDEXCOL DESC
protected java.lang.String getRemoveAtStmt()
DELETE FROM LISTTABLE WHERE OWNERCOL = ? AND INDEXCOL = ? [AND DISTINGUISHER=?]
protected java.lang.String getShiftStmt()
UPDATE LISTTABLE SET INDEXCOL = ? WHERE OWNERCOL = ? AND INDEXCOL = ? [AND DISTINGUISHER=?]
protected java.lang.String getIndicesOfStmt(java.util.Collection elements)
SELECT INDEXCOL FROM LISTTABLE
WHERE (OWNERCOL=? AND ELEMENT_COL=? [AND DISTINGUISHER=?]) OR
(OWNERCOL=? AND ELEMENT_COL=? [AND DISTINGUISHER=?]) OR
(OWNERCOL=? AND ELEMENT_COL=? [AND DISTINGUISHER=?])
ORDER BY INDEXCOL DESC
elements - The elements to retrieve the indices for.
protected void prepareIndicesOfStmt(org.jpox.StateManager sm,
java.sql.PreparedStatement ps,
java.util.Collection elements)
sm - State Manager of the container.ps - The Prepared Statementelements - Collection of elements
protected void internalRemoveAt(org.jpox.StateManager sm,
int index,
java.lang.String stmt,
int size)
sm - The state manager.index - The locationstmt - The statement to remove the element from the Listsize - Current list size (if known). -1 if not known
protected int[] internalShift(org.jpox.StateManager ownerSM,
org.jpox.ManagedConnection conn,
boolean batched,
int oldIndex,
int amount,
boolean executeNow)
throws java.sql.SQLException
ownerSM - StateManager of the ownerconn - The connectionbatched - Whether the statement is batchedoldIndex - The old indexamount - Amount to shift by (negative means shift down)executeNow - Whether to execute the statement now (or wait for batching)
java.sql.SQLException - Thrown if an error occurs
protected int[] getIndicesOf(org.jpox.StateManager sm,
java.util.Collection elements)
sm - The state manager.elements - The elements
protected java.util.List internalGetRange(org.jpox.StateManager sm,
int start,
int end)
sm - State Manager for the containerstart - Start position in the List.end - End position in the List.
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 | |||||||||