@RequestMapping(value={"/admin/update/","/admin/update"},method=RequestMethod.POST) @ResponseBody public RestWrapper updateOneRecord(@ModelAttribute("generalConfig") @Valid GeneralConfig generalConfig,BindingResult bindingResult,Principal principal){
  RestWrapper restWrapper=null;
  if (bindingResult.hasErrors()) {
    BindingResultError bindingResultError=new BindingResultError();
    return bindingResultError.errorMessage(bindingResult);
  }
  try {
    if (generalConfig.getRequired() <= 1) {
      com.wipro.ats.bdre.md.dao.jpa.GeneralConfig jpaGeneralConfigUpdate=new com.wipro.ats.bdre.md.dao.jpa.GeneralConfig();
      GeneralConfigId jpaGeneralConfigId=new GeneralConfigId();
      jpaGeneralConfigId.setConfigGroup(generalConfig.getConfigGroup());
      jpaGeneralConfigId.setGcKey(generalConfig.getKey());
      jpaGeneralConfigUpdate.setId(jpaGeneralConfigId);
      jpaGeneralConfigUpdate.setDefaultVal(generalConfig.getDefaultVal());
      jpaGeneralConfigUpdate.setDescription(generalConfig.getDescription());
      jpaGeneralConfigUpdate.setEnabled(generalConfig.isEnabled());
      jpaGeneralConfigUpdate.setGcValue(generalConfig.getValue());
      if (generalConfig.getRequired() == 1)       jpaGeneralConfigUpdate.setRequired(true);
 else       jpaGeneralConfigUpdate.setRequired(false);
      jpaGeneralConfigUpdate.setType(generalConfig.getType());
      LOGGER.info(generalConfig);
      generalConfigDAO.update(jpaGeneralConfigUpdate);
      restWrapper=new RestWrapper(generalConfig,RestWrapper.OK);
      LOGGER.info(" Record with key:" + jpaGeneralConfigId.getGcKey() + " and config group:"+ jpaGeneralConfigId.getConfigGroup()+ " updated in general_config by User:"+ principal.getName());
    }
 else {
      LOGGER.error("Invalid required field's data");
      restWrapper=new RestWrapper("Required field does not accest value other than 0 or 1",RestWrapper.ERROR);
    }
  }
 catch (  MetadataException e) {
    LOGGER.error(e);
    restWrapper=new RestWrapper(e.getMessage(),RestWrapper.ERROR);
  }
  return restWrapper;
}

@ RequestMapping ( value = { "/admin/update/" , "/admin/update" } , method = RequestMethod . POST ) @ ResponseBody public RestWrapper updateOneRecord ( @ ModelAttribute ( "generalConfig" ) @ Valid GeneralConfig generalConfig , BindingResult bindingResult , Principal principal ) { RestWrapper restWrapper = null ; if ( bindingResult . hasErrors ( ) ) { BindingResultError bindingResultError = new BindingResultError ( ) ; return bindingResultError . errorMessage ( bindingResult ) ; } try { if ( generalConfig . getRequired ( ) <= 1 ) { com . wipro . ats . bdre . md . dao . jpa . GeneralConfig jpaGeneralConfigUpdate = new com . wipro . ats . bdre . md . dao . jpa . GeneralConfig ( ) ; GeneralConfigId jpaGeneralConfigId = new GeneralConfigId ( ) ; jpaGeneralConfigId . setConfigGroup ( generalConfig . getConfigGroup ( ) ) ; jpaGeneralConfigId . setGcKey ( generalConfig . getKey ( ) ) ; jpaGeneralConfigUpdate . setId ( jpaGeneralConfigId ) ; jpaGeneralConfigUpdate . setDefaultVal ( generalConfig . getDefaultVal ( ) ) ; jpaGeneralConfigUpdate . setDescription ( generalConfig . getDescription ( ) ) ; jpaGeneralConfigUpdate . setEnabled ( generalConfig . isEnabled ( ) ) ; jpaGeneralConfigUpdate . setGcValue ( generalConfig . getValue ( ) ) ; if ( generalConfig . getRequired ( ) == 1 ) jpaGeneralConfigUpdate . setRequired ( true ) ; else jpaGeneralConfigUpdate . setRequired ( false ) ; jpaGeneralConfigUpdate . setType ( generalConfig . getType ( ) ) ; LOGGER . info ( generalConfig ) ; generalConfigDAO . update ( jpaGeneralConfigUpdate ) ; restWrapper = new RestWrapper ( generalConfig , RestWrapper . OK ) ; LOGGER . info ( " Record with key:" + jpaGeneralConfigId . getGcKey ( ) + " and config group:" + jpaGeneralConfigId . getConfigGroup ( ) + " updated in general_config by User:" + principal . getName ( ) ) ; } else { LOGGER . error ( "Invalid required field's data" ) ; restWrapper = new RestWrapper ( "Required field does not accest value other than 0 or 1" , RestWrapper . ERROR ) ; } } catch ( MetadataException e ) { LOGGER . error ( e ) ; restWrapper = new RestWrapper ( e . getMessage ( ) , RestWrapper . ERROR ) ; } return restWrapper ; }
this method updates a record in generalconfig table corresponding to object passed .
