I created an update method, however I'm having to create a variable to be able to update my property, which although working, I think this would not be the correct way to treat an object.
I have this property in the FunctionalModel object below the code below.
public void atualizar(FuncionarioModel funcionarioModel) throws NegocioException {
String cargo = funcionarioModel.getCargo();
funcionarioModel = this.funcionarioRepository.porId(funcionarioModel.getCodigo());
funcionarioModel.setCargo(cargo);
if (cargo.isEmpty()) {
throw new NegocioException("Não é possível fazer a Alteração campo cargo está vazio !");
}
}
If someone knows how I can fix this.