public abstract class ElementContainerStore extends BaseContainerStore
Modifier and Type | Class and Description |
---|---|
static class |
ElementContainerStore.ElementInfo
Inner class wrapping the information required for a valid element type.
|
Modifier and Type | Field and Description |
---|---|
protected String |
addStmt
Statement for adding an element to the container.
|
protected String |
clearStmt
Statement for clearing the container.
|
protected Table |
containerTable
Table containing the link between owner and element.
|
protected ElementContainerStore.ElementInfo[] |
elementInfo
Information for the elements of this container.
|
protected boolean |
elementIsPersistentInterface
Whether the element is of a persistent-interface (defined using "{interface}") type.
|
protected JavaTypeMapping |
elementMapping
Mapping for the element.
|
protected boolean |
elementsAreEmbedded
Whether the elements are embedded.
|
protected boolean |
elementsAreSerialised
Whether the elements are serialised.
|
protected String |
elementType
Type of the element.
|
protected org.datanucleus.metadata.AbstractClassMetaData |
emd
MetaData for the "element-type" class.
|
protected boolean |
iterateUsingDiscriminator
Flag to set whether the iterator statement will use a discriminator or not.
|
protected JavaTypeMapping |
orderMapping
Mapping for an ordering column to allow for duplicates in the container.
|
protected JavaTypeMapping |
relationDiscriminatorMapping
Optional mapping to distinguish elements of one collection from another when sharing the join table.
|
protected String |
relationDiscriminatorValue
Value to use to discriminate between elements of this collection from others using the same join table.
|
protected String |
removeStmt
Statement for removing an element from the container.
|
protected String |
sizeStmt
Statement for getting the size of the container.
|
protected boolean |
usingDiscriminatorInSizeStmt
Whether we are using a discriminator in the "size" statement.
|
allowNulls, clr, dba, ownerMapping, ownerMemberMetaData, relationType, storeMgr
Modifier | Constructor and Description |
---|---|
protected |
ElementContainerStore(RDBMSStoreManager storeMgr,
org.datanucleus.ClassLoaderResolver clr)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clear(org.datanucleus.state.ObjectProvider ownerOP)
Clear the association from owner to all elements.
|
void |
executeClear(org.datanucleus.state.ObjectProvider ownerOP) |
protected String |
getAddStmtForJoinTable()
Generates the statement for adding items.
|
protected String |
getClearStmt()
Generate statement for clearing the container.
|
Table |
getContainerTable() |
ElementContainerStore.ElementInfo[] |
getElementInfo() |
protected ElementContainerStore.ElementInfo[] |
getElementInformationForClass()
Convenience method to find the element information relating to the element type.
|
JavaTypeMapping |
getElementMapping() |
org.datanucleus.metadata.AbstractClassMetaData |
getEmd() |
JavaTypeMapping |
getOrderMapping() |
JavaTypeMapping |
getRelationDiscriminatorMapping() |
String |
getRelationDiscriminatorValue() |
int |
getSize(org.datanucleus.state.ObjectProvider ownerOP) |
protected String |
getSizeStmt()
Generate statement for getting the size of thecontainer.
|
boolean |
hasOrderMapping()
Accessor for whether the store has an order mapping, to allow for duplicates or ordering.
|
protected void |
invalidateAddStmt()
Method to remove any stored statement for addition of an element.
|
boolean |
isElementsAreEmbedded() |
boolean |
isElementsAreSerialised() |
abstract Iterator |
iterator(org.datanucleus.state.ObjectProvider ownerOP)
Accessor for an iterator through the container elements.
|
int |
size(org.datanucleus.state.ObjectProvider op)
Method to return the size of the container.
|
protected boolean |
validateElementForReading(org.datanucleus.state.ObjectProvider op,
Object element)
Method to check if an element is already persistent or is persistent but managed by
a different persistence manager.
|
protected boolean |
validateElementForWriting(org.datanucleus.ExecutionContext ec,
Object element,
org.datanucleus.store.FieldValues fieldValues)
Method to check if an element is already persistent, or is managed by a different
Persistencemanager.
|
protected boolean |
validateElementType(org.datanucleus.ClassLoaderResolver clr,
Object element)
Method to validate an element against the accepted type.
|
allowsBatching, getDatastoreAdapter, getObjectProviderForEmbeddedPCObject, getOwnerMapping, getOwnerMemberMetaData, getRelationType, getStoreManager, isEmbeddedMapping, setOwner
protected boolean iterateUsingDiscriminator
protected String sizeStmt
protected String clearStmt
protected String addStmt
protected String removeStmt
protected boolean usingDiscriminatorInSizeStmt
protected ElementContainerStore.ElementInfo[] elementInfo
protected org.datanucleus.metadata.AbstractClassMetaData emd
protected Table containerTable
protected JavaTypeMapping elementMapping
protected String elementType
protected boolean elementsAreEmbedded
protected boolean elementsAreSerialised
protected boolean elementIsPersistentInterface
protected JavaTypeMapping orderMapping
protected JavaTypeMapping relationDiscriminatorMapping
protected String relationDiscriminatorValue
protected ElementContainerStore(RDBMSStoreManager storeMgr, org.datanucleus.ClassLoaderResolver clr)
storeMgr
- Manager for the storeclr
- ClassLoader resolverpublic ElementContainerStore.ElementInfo[] getElementInfo()
public JavaTypeMapping getElementMapping()
public JavaTypeMapping getOrderMapping()
public JavaTypeMapping getRelationDiscriminatorMapping()
public String getRelationDiscriminatorValue()
public Table getContainerTable()
public org.datanucleus.metadata.AbstractClassMetaData getEmd()
public boolean isElementsAreSerialised()
public boolean isElementsAreEmbedded()
protected ElementContainerStore.ElementInfo[] getElementInformationForClass()
public boolean hasOrderMapping()
protected boolean validateElementType(org.datanucleus.ClassLoaderResolver clr, Object element)
clr
- The ClassLoaderResolverelement
- The element to validateprotected boolean validateElementForReading(org.datanucleus.state.ObjectProvider op, Object element)
op
- The ObjectProvider of this ownerelement
- The elementprotected boolean validateElementForWriting(org.datanucleus.ExecutionContext ec, Object element, org.datanucleus.store.FieldValues fieldValues)
ec
- execution contextelement
- The elementfieldValues
- any initial field values to use if persisting the elementpublic abstract Iterator iterator(org.datanucleus.state.ObjectProvider ownerOP)
ownerOP
- ObjectProvider for the container.public void clear(org.datanucleus.state.ObjectProvider ownerOP)
ownerOP
- ObjectProvider for the container.public int size(org.datanucleus.state.ObjectProvider op)
op
- The ObjectProvider.protected void invalidateAddStmt()
protected String getAddStmtForJoinTable()
INSERT INTO COLLTABLE (OWNERCOL,[ELEMENTCOL],[EMBEDDEDFIELD1, EMBEDDEDFIELD2,...],[ORDERCOL]) VALUES (?,?,?)
public void executeClear(org.datanucleus.state.ObjectProvider ownerOP)
protected String getClearStmt()
DELETE FROM CONTAINERTABLE WHERE OWNERCOL = ? [AND RELATION_DISCRIM=?]TODO Add a discriminator restriction on this statement so we only clear ones with a valid discriminator value
public int getSize(org.datanucleus.state.ObjectProvider ownerOP)
protected String getSizeStmt()
SELECT COUNT(*) FROM TBL THIS [INNER JOIN ELEM_TBL ELEM ON TBL.COL = ELEM.ID] - when no null [LEFT OUTER JOIN ELEM_TBL ELEM ON TBL.COL = ELEM.ID] - when allows null WHERE THIS.OWNERCOL=? [AND THIS.ORDERCOL IS NOT NULL] [AND (DISCRIMINATOR=? OR DISCRMINATOR=? OR DISCRIMINATOR=? [OR DISCRIMINATOR IS NULL])] [AND RELATION_DISCRIM=?]The discriminator part includes all subclasses of the element type. If the element is in a different table to the container then an INNER JOIN will be present to link the two tables, and table aliases will be present also. TODO Update this to allow for getting the size when more than 1 element table.
Copyright © 2015. All rights reserved.