Class UpdateRequest.UpdateMappingConsumer

  • All Implemented Interfaces:
    MappingConsumer
    Enclosing class:
    UpdateRequest

    private class UpdateRequest.UpdateMappingConsumer
    extends java.lang.Object
    implements MappingConsumer
    Mapping Consumer used for generating the UPDATE statement for an object in a table. This statement will be of the form
     UPDATE table-name SET param1=?,param2=? 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}
     
    • Field Detail

      • initialized

        boolean initialized
        Flag for initialisation state of the consumer.
      • paramIndex

        int paramIndex
        Current parameter index.
      • updateFields

        java.util.List updateFields
        Numbers of all fields to be updated.
      • whereFields

        java.util.List whereFields
        Numbers of all WHERE clause fields.
      • postSetMappings

        java.util.List<JavaTypeMapping> postSetMappings
        Mappings that require post-set processing.
      • callbackMappings

        java.util.List<MappingCallbacks> callbackMappings
        Mappings that require callbacks calling.
      • columnAssignments

        java.lang.StringBuilder columnAssignments
        for UPDATE statement
      • assignedColumns

        java.util.Map assignedColumns
      • where

        java.lang.StringBuilder where
        Where clause for the statement. Built during the consumption process.
      • cmd

        private final org.datanucleus.metadata.AbstractClassMetaData cmd
        MetaData for the class of the object
      • whereClauseConsumption

        private boolean whereClauseConsumption
    • Constructor Detail

      • UpdateMappingConsumer

        public UpdateMappingConsumer​(org.datanucleus.metadata.AbstractClassMetaData cmd)
        Constructor
        Parameters:
        cmd - metadata for the class
    • Method Detail

      • setWhereClauseConsumption

        public void setWhereClauseConsumption​(boolean whereClause)
      • preConsumeMapping

        public void preConsumeMapping​(int highest)
        Description copied from interface: MappingConsumer
        This method is called before consuming the mappings
        Specified by:
        preConsumeMapping in interface MappingConsumer
        Parameters:
        highest - the highest number for the fields that are going to be provided in the consumer
      • consumeMapping

        public void consumeMapping​(JavaTypeMapping m,
                                   org.datanucleus.metadata.AbstractMemberMetaData mmd)
        Consumes a mapping for a field.
        Specified by:
        consumeMapping in interface MappingConsumer
        Parameters:
        m - The mapping.
        mmd - MetaData for the field
      • consumeMapping

        public void consumeMapping​(JavaTypeMapping m,
                                   MappingType mappingType)
        Consumes a mapping associated to surrogate / special columns.
        Specified by:
        consumeMapping in interface MappingConsumer
        Parameters:
        m - The mapping.
        mappingType - the Mapping type
      • getPostSetMappings

        public java.util.List<JavaTypeMapping> getPostSetMappings()
      • getMappingCallbacks

        public java.util.List<MappingCallbacks> getMappingCallbacks()
      • getUpdateFieldNumbers

        public int[] getUpdateFieldNumbers()
        Accessor for the numbers of fields to be updated (excluding PK fields).
        Returns:
        array of absolute field numbers
      • getWhereFieldNumbers

        public int[] getWhereFieldNumbers()
        Accessor for the numbers of fields in the WHERE clause.
        Returns:
        array of absolute WHERE clause field numbers
      • getStatement

        public java.lang.String getStatement()
        Accessor for the basic update SQL statement.
         UPDATE TABLE SET COL1 = ?, COL2 = ? WHERE COL3 = ? AND COL4 = ? 
         
        Returns:
        The update SQL statement