Class JoinPersistableRelationStore
java.lang.Object
org.datanucleus.store.rdbms.scostore.JoinPersistableRelationStore
- All Implemented Interfaces:
org.datanucleus.store.types.scostore.PersistableRelationStore
,org.datanucleus.store.types.scostore.Store
public class JoinPersistableRelationStore
extends Object
implements org.datanucleus.store.types.scostore.PersistableRelationStore
RDBMS implementation of a persistable relation backing store.
Represents an N-1 unidirectional join table relation, and manages the access to the join table.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
Statement for adding a relation to the join table.protected org.datanucleus.ClassLoaderResolver
ClassLoader resolver.protected DatastoreAdapter
Datastore adapter in use by this store.protected PersistableJoinTable
Table containing the link between owner and related object.protected JavaTypeMapping
Mapping to the owner of the relation (which holds the member).protected org.datanucleus.metadata.AbstractMemberMetaData
MetaData for the member in the owner.protected String
Statement for removing a relation from the join table.protected RDBMSStoreManager
Manager for the store.protected String
Statement for updating a relation to the join table. -
Constructor Summary
ConstructorsConstructorDescriptionJoinPersistableRelationStore
(org.datanucleus.metadata.AbstractMemberMetaData mmd, PersistableJoinTable joinTable, org.datanucleus.ClassLoaderResolver clr) Constructor for a persistable relation join store for RDBMS. -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(org.datanucleus.state.DNStateManager sm1, org.datanucleus.state.DNStateManager sm2) protected String
Generates the statement for adding items.org.datanucleus.metadata.AbstractMemberMetaData
protected String
Generates the statement for removing items.org.datanucleus.store.StoreManager
protected String
Generates the statement for updating items.static int
populateOwnerInStatement
(org.datanucleus.state.DNStateManager sm, org.datanucleus.ExecutionContext ec, PreparedStatement ps, int jdbcPosition, PersistableJoinTable joinTable) Convenience method to populate the passed PreparedStatement with the value from the owner.boolean
remove
(org.datanucleus.state.DNStateManager sm) boolean
update
(org.datanucleus.state.DNStateManager sm1, org.datanucleus.state.DNStateManager sm2)
-
Field Details
-
storeMgr
Manager for the store. -
dba
Datastore adapter in use by this store. -
ownerMapping
Mapping to the owner of the relation (which holds the member). -
ownerMemberMetaData
protected org.datanucleus.metadata.AbstractMemberMetaData ownerMemberMetaDataMetaData for the member in the owner. -
joinTable
Table containing the link between owner and related object. -
clr
protected org.datanucleus.ClassLoaderResolver clrClassLoader resolver. -
addStmt
Statement for adding a relation to the join table. -
updateStmt
Statement for updating a relation to the join table. -
removeStmt
Statement for removing a relation from the join table.
-
-
Constructor Details
-
JoinPersistableRelationStore
public JoinPersistableRelationStore(org.datanucleus.metadata.AbstractMemberMetaData mmd, PersistableJoinTable joinTable, org.datanucleus.ClassLoaderResolver clr) Constructor for a persistable relation join store for RDBMS.- Parameters:
mmd
- owner member metadatajoinTable
- The join tableclr
- The ClassLoaderResolver
-
-
Method Details
-
getStoreManager
public org.datanucleus.store.StoreManager getStoreManager()- Specified by:
getStoreManager
in interfaceorg.datanucleus.store.types.scostore.Store
-
getOwnerMemberMetaData
public org.datanucleus.metadata.AbstractMemberMetaData getOwnerMemberMetaData()- Specified by:
getOwnerMemberMetaData
in interfaceorg.datanucleus.store.types.scostore.Store
-
add
public boolean add(org.datanucleus.state.DNStateManager sm1, org.datanucleus.state.DNStateManager sm2) - Specified by:
add
in interfaceorg.datanucleus.store.types.scostore.PersistableRelationStore
-
remove
public boolean remove(org.datanucleus.state.DNStateManager sm) - Specified by:
remove
in interfaceorg.datanucleus.store.types.scostore.PersistableRelationStore
-
update
public boolean update(org.datanucleus.state.DNStateManager sm1, org.datanucleus.state.DNStateManager sm2) - Specified by:
update
in interfaceorg.datanucleus.store.types.scostore.PersistableRelationStore
-
getAddStmt
Generates the statement for adding items.INSERT INTO JOINTABLE (OWNER_COL, RELATED_COL) VALUES (?,?)
- Returns:
- The Statement for adding an item
-
getUpdateStmt
Generates the statement for updating items.UPDATE JOINTABLE SET RELATED_COL = ? WHERE OWNER_COL = ?
- Returns:
- The Statement for updating an item
-
getRemoveStmt
Generates the statement for removing items.DELETE FROM JOINTABLE WHERE OWNER_COL = ?
- Returns:
- The Statement for removing an item
-
populateOwnerInStatement
public static int populateOwnerInStatement(org.datanucleus.state.DNStateManager sm, org.datanucleus.ExecutionContext ec, PreparedStatement ps, int jdbcPosition, PersistableJoinTable joinTable) Convenience method to populate the passed PreparedStatement with the value from the owner.- Parameters:
sm
- StateManagerec
- execution contextps
- The PreparedStatementjdbcPosition
- Position in JDBC statement to populatejoinTable
- Join table- Returns:
- The next position in the JDBC statement
-