Class DeleteRequest
- java.lang.Object
-
- org.datanucleus.store.rdbms.request.Request
-
- org.datanucleus.store.rdbms.request.DeleteRequest
-
public class DeleteRequest extends Request
Class to provide a means of deletion of records from an RDBMS. Extends basic request class implementing the execute method to do a JDBC delete operation. Provides a version check for optimistic handling. The SQL will be of the formDELETE FROM TBL_NAME WHERE id1=? AND id2=?
or, if "soft delete" is being used for this type, thenUPDATE TBL_NAME SET DELETE_COL=TRUE WHERE id1=? AND id2=?
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
DeleteRequest.DeleteMappingConsumer
Mapping Consumer used for generating the DELETE statement for an object in a table.
-
Field Summary
Fields Modifier and Type Field Description protected org.datanucleus.metadata.AbstractClassMetaData
cmd
MetaData for the class.private java.lang.String
deleteStmt
Statement for deleting the object from the datastore.private java.lang.String
deleteStmtOptimistic
Statement for deleting the object from the datastore (optimistic txns).private java.util.List<MappingCallbacks>
mappingCallbacks
private StatementMappingDefinition
mappingStatementIndex
the index for the expression(s) in the delete statement.private StatementMappingIndex
multitenancyStatementMapping
StatementExpressionIndex for multitenancy.private org.datanucleus.metadata.AbstractMemberMetaData[]
oneToOneNonOwnerFields
1-1 bidir non-owner fields that are reachable (but not updated) and have no datastore column.private java.lang.String
softDeleteStmt
Statement for soft-deleting the object from the datastore.protected boolean
versionChecks
Whether we should make checks on optimistic version before updating.protected org.datanucleus.metadata.VersionMetaData
versionMetaData
MetaData for the version handling.private int[]
whereFieldNumbers
PK fields to be provided in defining the record to be deleted (app identity cases).
-
Constructor Summary
Constructors Constructor Description DeleteRequest(DatastoreClass table, org.datanucleus.metadata.AbstractClassMetaData cmd, org.datanucleus.ClassLoaderResolver clr)
Constructor, taking the table.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute(org.datanucleus.state.DNStateManager sm)
Method performing the deletion of the record from the datastore.private void
updateOneToOneBidirectionalOwnerObjectForField(org.datanucleus.state.DNStateManager sm, org.datanucleus.metadata.AbstractMemberMetaData mmd)
Method to update any 1-1 bidir non-owner fields where the foreign-key is stored in the other object.
-
-
-
Field Detail
-
mappingCallbacks
private final java.util.List<MappingCallbacks> mappingCallbacks
-
deleteStmt
private final java.lang.String deleteStmt
Statement for deleting the object from the datastore.
-
deleteStmtOptimistic
private final java.lang.String deleteStmtOptimistic
Statement for deleting the object from the datastore (optimistic txns).
-
softDeleteStmt
private final java.lang.String softDeleteStmt
Statement for soft-deleting the object from the datastore.
-
mappingStatementIndex
private StatementMappingDefinition mappingStatementIndex
the index for the expression(s) in the delete statement.
-
multitenancyStatementMapping
private StatementMappingIndex multitenancyStatementMapping
StatementExpressionIndex for multitenancy.
-
whereFieldNumbers
private final int[] whereFieldNumbers
PK fields to be provided in defining the record to be deleted (app identity cases).
-
oneToOneNonOwnerFields
private final org.datanucleus.metadata.AbstractMemberMetaData[] oneToOneNonOwnerFields
1-1 bidir non-owner fields that are reachable (but not updated) and have no datastore column.
-
cmd
protected org.datanucleus.metadata.AbstractClassMetaData cmd
MetaData for the class.
-
versionMetaData
protected org.datanucleus.metadata.VersionMetaData versionMetaData
MetaData for the version handling.
-
versionChecks
protected boolean versionChecks
Whether we should make checks on optimistic version before updating.
-
-
Constructor Detail
-
DeleteRequest
public DeleteRequest(DatastoreClass table, org.datanucleus.metadata.AbstractClassMetaData cmd, org.datanucleus.ClassLoaderResolver clr)
Constructor, taking the table. Uses the structure of the datastore table to build a basic query.- Parameters:
table
- The Class Table representing the datastore table to delete.cmd
- ClassMetaData of objects being deletedclr
- ClassLoader resolver
-
-
Method Detail
-
execute
public void execute(org.datanucleus.state.DNStateManager sm)
Method performing the deletion of the record from the datastore. Takes the constructed deletion query and populates with the specific record information.
-
updateOneToOneBidirectionalOwnerObjectForField
private void updateOneToOneBidirectionalOwnerObjectForField(org.datanucleus.state.DNStateManager sm, org.datanucleus.metadata.AbstractMemberMetaData mmd)
Method to update any 1-1 bidir non-owner fields where the foreign-key is stored in the other object.- Parameters:
sm
- StateManager of this objectmmd
- MetaData for field that has related (owner) objects
-
-