@Transactional @Override public CommandProcessingResult updateGLClosure( final Long glClosureId, final JsonCommand command) { final GLClosureCommand closureCommand = this.fromApiJsonDeserializer.commandFromApiJson(command.json()); closureCommand.validateForUpdate(); // is the glClosure valid final GLClosure glClosure = this.glClosureRepository.findOne(glClosureId); if (glClosure == null) { throw new GLClosureNotFoundException(glClosureId); } final Map<String, Object> changesOnly = glClosure.update(command); if (!changesOnly.isEmpty()) { this.glClosureRepository.saveAndFlush(glClosure); } return new CommandProcessingResultBuilder() .withCommandId(command.commandId()) .withOfficeId(glClosure.getOffice().getId()) .withEntityId(glClosure.getId()) .with(changesOnly) .build(); }