Class UpdateRequest


  • public class UpdateRequest
    extends Request
    Class to provide a means of update of particular fields of a particular type in an RDBMS. Extends basic request class implementing the execute method to do a JDBC update operation. The SQL will be of the form
     UPDATE table-name SET param1=?, param2=?[, version=?] WHERE id1=? AND id2=?
     
    or (when also performing version checks)
     UPDATE table-name SET param1=?, param2=?, version={newvers} WHERE id1=? AND id2=? AND version={oldvers}
     
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private class  UpdateRequest.UpdateMappingConsumer
      Mapping Consumer used for generating the UPDATE statement for an object in a table.
    • Constructor Summary

      Constructors 
      Constructor Description
      UpdateRequest​(DatastoreClass table, org.datanucleus.metadata.AbstractMemberMetaData[] reqFieldMetaData, 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 update of the record in the datastore.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • updateStmt

        private final java.lang.String updateStmt
        SQL statement for the update.
      • updateStmtOptimistic

        private final java.lang.String updateStmtOptimistic
        SQL statement for the update when using optimistic txns.
      • mappingCallbacks

        private final java.util.List<MappingCallbacks> mappingCallbacks
        callback mappings will have their postUpdate method called after the update
      • postSetMappings

        private final java.util.List<JavaTypeMapping> postSetMappings
      • stmtMappingDefinition

        private StatementMappingDefinition stmtMappingDefinition
        the index for the expression in the update sql statement.
      • updateFieldNumbers

        private final int[] updateFieldNumbers
        Numbers of all fields to be updated (except PK).
      • whereFieldNumbers

        private final int[] whereFieldNumbers
        Numbers of WHERE clause fields.
      • 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.
      • updateUserStmtMapping

        private StatementMappingIndex updateUserStmtMapping
        StatementExpressionIndex for update-user.
      • updateTimestampStmtMapping

        private StatementMappingIndex updateTimestampStmtMapping
        StatementExpressionIndex for update-timestamp.
    • Constructor Detail

      • UpdateRequest

        public UpdateRequest​(DatastoreClass table,
                             org.datanucleus.metadata.AbstractMemberMetaData[] reqFieldMetaData,
                             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 update
        reqFieldMetaData - MetaData of the fields to update
        cmd - ClassMetaData of objects being updated
        clr - ClassLoader resolver
    • Method Detail

      • execute

        public void execute​(org.datanucleus.state.DNStateManager sm)
        Method performing the update of the record in the datastore. Takes the constructed update query and populates with the specific record information.
        Specified by:
        execute in class Request
        Parameters:
        sm - StateManager for the record to be updated