@RequestMapping(value={"/",""},method=RequestMethod.POST) @ResponseBody public RestWrapper update(@ModelAttribute("batch") @Valid Batch batch,BindingResult bindingResult,Principal principal){
  RestWrapper restWrapper=null;
  if (bindingResult.hasErrors()) {
    BindingResultError bindingResultError=new BindingResultError();
    return bindingResultError.errorMessage(bindingResult);
  }
  try {
    com.wipro.ats.bdre.md.dao.jpa.Batch jpaBatch=new com.wipro.ats.bdre.md.dao.jpa.Batch();
    jpaBatch.setBatchId(batch.getBatchId());
    jpaBatch.setBatchType(batch.getBatchType());
    InstanceExec instanceExec=new InstanceExec();
    if (batch.getSourceInstanceExecId() != null) {
      instanceExec.setInstanceExecId(batch.getSourceInstanceExecId());
      jpaBatch.setInstanceExec(instanceExec);
    }
    batchDAO.update(jpaBatch);
    restWrapper=new RestWrapper(batch,RestWrapper.OK);
    LOGGER.info(RECORDWITHID + batch.getBatchId() + " updated in Batch by User:"+ principal.getName()+ batch);
  }
 catch (  MetadataException e) {
    LOGGER.error(e);
    restWrapper=new RestWrapper(e.getMessage(),RestWrapper.ERROR);
  }
  return restWrapper;
}

@ RequestMapping ( value = { "/" , "" } , method = RequestMethod . POST ) @ ResponseBody public RestWrapper update ( @ ModelAttribute ( "batch" ) @ Valid Batch batch , BindingResult bindingResult , Principal principal ) { RestWrapper restWrapper = null ; if ( bindingResult . hasErrors ( ) ) { BindingResultError bindingResultError = new BindingResultError ( ) ; return bindingResultError . errorMessage ( bindingResult ) ; } try { com . wipro . ats . bdre . md . dao . jpa . Batch jpaBatch = new com . wipro . ats . bdre . md . dao . jpa . Batch ( ) ; jpaBatch . setBatchId ( batch . getBatchId ( ) ) ; jpaBatch . setBatchType ( batch . getBatchType ( ) ) ; InstanceExec instanceExec = new InstanceExec ( ) ; if ( batch . getSourceInstanceExecId ( ) != null ) { instanceExec . setInstanceExecId ( batch . getSourceInstanceExecId ( ) ) ; jpaBatch . setInstanceExec ( instanceExec ) ; } batchDAO . update ( jpaBatch ) ; restWrapper = new RestWrapper ( batch , RestWrapper . OK ) ; LOGGER . info ( RECORDWITHID + batch . getBatchId ( ) + " updated in Batch by User:" + principal . getName ( ) + batch ) ; } catch ( MetadataException e ) { LOGGER . error ( e ) ; restWrapper = new RestWrapper ( e . getMessage ( ) , RestWrapper . ERROR ) ; } return restWrapper ; }
this method calls proc updatebatch and updates the values of the batch object passed . it also validates the values of the object passed .
