|
|||||||||||
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
org.jpox.store.rdbms.scostore.AbstractCollectionStore
org.jpox.store.rdbms.scostore.AbstractListStore
org.jpox.store.rdbms.scostore.FKListStore
Representation of an Inverse List as part of a relationship. This class is used where you have a 1-N and the tables are not joined via a join table. There is an owner table and an element table, and the element table has a column being the id of the owner table. This is in contrast to NormalListStore which represents 1-N relationships using a join table. There are 2 possible uses here
Nested Class Summary |
Nested classes inherited from class org.jpox.store.rdbms.scostore.ElementContainerStore |
ElementContainerStore.ElementInfo |
Field Summary | |
protected java.lang.String |
addStmt
|
protected java.lang.String |
indexOfStmt
|
protected java.lang.String |
lastIndexOfStmt
|
protected java.lang.String |
listName
|
protected java.lang.String |
removeAtStmt
|
protected java.lang.String |
setStmt
|
protected java.lang.String |
shiftStmt
|
Fields inherited from class org.jpox.store.rdbms.scostore.AbstractCollectionStore |
containsStmt |
Fields inherited from class org.jpox.store.rdbms.scostore.ElementContainerStore |
clearStmt, clr, containerTable, dba, elementInfo, elementMapping, elementsAreEmbedded, elementsAreSerialised, elementType, elmIdentifier, emd, iterateUsingDiscriminator, LOCALISER, orderMapping, ownerFieldMetaData, ownerMapping, relationDiscriminatorMapping, relationDiscriminatorValue, sizeStmt, storeMgr, thisIdentifier |
Constructor Summary | |
FKListStore(AbstractPropertyMetaData fmd,
RDBMSManager storeMgr,
ClassLoaderResolver clr)
Constructor. |
Method Summary | |
void |
add(StateManager sm,
int index,
java.lang.Object element)
Method to add an element to the List. |
boolean |
add(StateManager sm,
java.lang.Object element)
Method to add an element to the List. |
boolean |
addAll(StateManager sm,
java.util.Collection elements)
Method to add a collection of elements to the List. |
boolean |
addAll(StateManager sm,
java.util.Collection c,
boolean initialising)
Method to add all elements from a Collection to the List. |
boolean |
addAll(StateManager sm,
int index,
java.util.Collection c)
Method to add all elements from a Collection to the List. |
void |
clear(StateManager ownerSM)
Method to clear the List. |
java.lang.Object |
get(StateManager sm,
int index)
Method to retrieve an element from the List. |
protected java.lang.String |
getClearNullifyStmt()
Generates the statement for clearing items by nulling the owner link out. |
protected java.lang.String |
getClearStmt()
Generate statement for clearing the container. |
protected java.lang.String |
getContainsStmt()
Generate statement for retrieving the contents of the Collection. |
protected java.lang.String |
getIndexOfStmt()
Generate statement for getting the index of an item. |
protected java.lang.String |
getIndicesOfStmt(java.util.Collection elements)
Generates the statement for getting the indices of a collection of element. |
protected QueryExpression |
getIteratorStatement(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. |
protected java.lang.String |
getRemoveAtNullifyStmt()
Generates the statement for removing an item by nulling it out. |
protected java.lang.String |
getRemoveAtStmt()
Generates the statement for removing an item. |
protected java.lang.String |
getSetStmt()
Generates the statement for setting an item to be at a position. |
protected java.lang.String |
getShiftStmt()
Generates the statement for shifting items. |
protected java.lang.String |
getSizeStmt()
Generate statement for getting the size of the container. |
protected java.lang.String |
getUnsetStmt()
Generates the statement for unsetting an item from a list position. |
int |
indexOf(StateManager sm,
java.lang.Object element)
Accessor for the indexOf an object in the List. |
protected void |
initialiseStatements()
Method to initialise the statements being used. |
protected boolean |
internalAdd(StateManager sm,
int startAt,
boolean atEnd,
java.util.Collection c,
boolean initialising)
Internal method for adding an item to the List. |
protected java.util.List |
internalGetRange(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 void |
internalRemoveAt(StateManager sm,
int index,
java.lang.String stmt)
Internal method to remove an object at a location in the List. |
java.util.Iterator |
iterator(StateManager sm)
Accessor for an iterator through the list elements. |
ScalarExpression |
joinElementsTo(QueryExpression stmt,
QueryExpression parentStmt,
JavaTypeMapping ownerMapping,
LogicSetExpression ownerTe,
DatastoreIdentifier listRangeVar,
java.lang.Class filteredElementType,
ScalarExpression elmExpr,
DatastoreIdentifier elementRangeVar)
Method used in queries when contains() has been invoked. |
int |
lastIndexOf(StateManager sm,
java.lang.Object element)
Method to retrieve the last index of an object in the list. |
java.util.ListIterator |
listIterator(StateManager sm)
Accessor for an iterator through the list elements. |
java.util.ListIterator |
listIterator(StateManager ownerSM,
int start)
Accessor for an iterator through the list elements. |
QueryExpression |
newQueryStatement(StateManager sm,
java.lang.String candidateClass)
Utility method to return a new QueryStatement for retrieval of the elements of this List. |
protected void |
prepareIndicesOfStmt(StateManager sm,
java.sql.PreparedStatement ps,
java.util.Collection elements)
Method to prepare the indicesOf statement for use. |
java.lang.Object |
remove(StateManager sm,
int index)
Method to remove an object at a location in the List. |
boolean |
remove(StateManager sm,
java.lang.Object element)
Method to remove an element from the List. |
boolean |
removeAll(StateManager sm,
java.util.Collection elements)
Remove all elements from a collection from the association owner vs elements. |
protected void |
removeAt(StateManager sm,
int index)
Internal method to remove an object at a location in the List. |
java.lang.Object |
set(StateManager sm,
int index,
java.lang.Object element,
boolean allowDependentField)
Method to set an object in the List at a position. |
java.util.List |
subList(StateManager sm,
int start,
int end)
Method to retrieve a list of elements in a range. |
protected void |
validateElementForWriting(StateManager sm,
java.lang.Object element)
Method to validate that an element is valid for writing to the datastore. |
Methods inherited from class org.jpox.store.rdbms.scostore.AbstractCollectionStore |
contains, 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 |
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 listName
protected java.lang.String addStmt
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
Constructor Detail |
public FKListStore(AbstractPropertyMetaData fmd, RDBMSManager storeMgr, ClassLoaderResolver clr)
fmd
- Field MetaData for the field that this representsstoreMgr
- The Store Manager in useclr
- The ClassLoaderResolverMethod Detail |
protected java.lang.String getSetStmt()
UPDATE LISTTABLE SET OWNERCOL=?, INDEXCOL = ? [,DISTINGUISHER=?] WHERE ELEMENTCOL = ?
protected java.lang.String getUnsetStmt()
UPDATE LISTTABLE SET OWNERCOL=NULL, INDEXCOL = NULL [, DISTINGUISHER = NULL] WHERE OWNERCOL = ? AND INDEXCOL = ? [AND DISTINGUISHER = ?]
public java.lang.Object set(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 enable dependent-field deletes during the set
protected QueryExpression getIteratorStatement(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.
protected boolean internalAdd(StateManager sm, int startAt, boolean atEnd, java.util.Collection c, boolean initialising)
sm
- The state managerstartAt
- The start positionatEnd
- Whether to add at the endc
- The Collection of elements to add.initialising
- Whether we are initialising the list with these elements
protected java.lang.String getRemoveAtNullifyStmt()
UPDATE LISTTABLE SET OWNERCOL = NULL, INDEXCOL = NULL WHERE OWNERCOL = ? AND INDEXCOL = ? [AND DISTINGUISHER = ?]and when there are multiple element tables the statement will be
UPDATE ? SET OWNERCOL=NULL, INDEXCOL=NULL WHERE OWNERCOL=? AND INDEXCOL=? [AND DISTINGUISHER = ?]
public boolean remove(StateManager sm, java.lang.Object element)
sm
- The state managerelement
- The element to remove.
protected void removeAt(StateManager sm, int index)
sm
- The state manager.index
- The locationprotected java.lang.String getClearNullifyStmt()
UPDATE LISTTABLE SET OWNERCOL=NULL, INDEXCOL=NULL [,DISTINGUISHER=NULL] WHERE OWNERCOL=? [AND DISTINGUISHER=?]when there is only one element table, and will be
UPDATE ? SET OWNERCOL=NULL, INDEXCOL=NULL [,DISTINGUISHER=NULL] WHERE OWNERCOL=? [AND DISTINGUISHER=?]when there is more than 1 element table.
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 getClearStmt()
DELETE FROM CONTAINERTABLE WHERE OWNERCOL = ?
getClearStmt
in class ElementContainerStore
public void clear(StateManager ownerSM)
clear
in interface CollectionStore
clear
in class ElementContainerStore
ownerSM
- The state managerprotected void validateElementForWriting(StateManager sm, java.lang.Object element)
validateElementForWriting
in class ElementContainerStore
sm
- StateManager for the Listelement
- The element to validatepublic 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 listRangeVar, 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 ownerlistRangeVar
- The range variable for the "List" 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 sm)
iterator
in interface CollectionStore
iterator
in class ElementContainerStore
sm
- State Manager for the container.
public java.util.ListIterator listIterator(StateManager sm)
listIterator
in interface ListStore
sm
- State Manager for the container.
public java.util.ListIterator listIterator(StateManager ownerSM, int start)
listIterator
in interface ListStore
ownerSM
- State Manager for the container.start
- The start point in the list.
public boolean add(StateManager sm, java.lang.Object element)
add
in interface CollectionStore
sm
- The state managerelement
- The element to remove
public void add(StateManager sm, int index, java.lang.Object element)
add
in interface ListStore
sm
- The state manager.index
- The location to add atelement
- The element to add.public boolean addAll(StateManager sm, java.util.Collection elements)
addAll
in interface CollectionStore
sm
- The state managerelements
- The elements to remove
public boolean addAll(StateManager sm, int index, java.util.Collection c)
addAll
in interface ListStore
sm
- The state managerindex
- The location to add atc
- The collection
public boolean addAll(StateManager sm, java.util.Collection c, boolean initialising)
addAll
in interface ListStore
sm
- The state managerc
- The collectioninitialising
- Whether we are initialising the list with these elements
public java.lang.Object get(StateManager sm, int index)
get
in interface ListStore
sm
- The state managerindex
- The location of the element.
public int indexOf(StateManager sm, java.lang.Object element)
indexOf
in interface ListStore
sm
- The state managerelement
- The element.
public int lastIndexOf(StateManager sm, java.lang.Object element)
lastIndexOf
in interface ListStore
sm
- The state manager.element
- The object
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 java.lang.Object remove(StateManager sm, int index)
remove
in interface ListStore
sm
- The state manager.index
- The location
public java.util.List subList(StateManager sm, int start, int end)
subList
in interface ListStore
sm
- 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 ELEMENTCOL = ? 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(StateManager sm, java.sql.PreparedStatement ps, java.util.Collection elements)
sm
- State Manager of the container.ps
- The Prepared Statementelements
- Collection of elementsprotected void internalRemoveAt(StateManager sm, int index, java.lang.String stmt)
sm
- The state manager.index
- The locationstmt
- The statement to remove the element from the Listprotected java.util.List internalGetRange(StateManager sm, int start, int end)
sm
- State Manager for the containerstart
- Start position in the List.end
- End position in the List.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |