I have a Java Spring MVC application, with Hibernate and JPA and HTML interface.
I have two forms that depend on the CadernoCadastrados class and their attributes.
In the first form I enter the data of a new Notebook, saved in the database and a new ID is created for that record.
When I do a search, in case number = 44, the second form is displayed, which comes with some fields of the first form already filled in, but disabled, and additional fields of the Notebook class enabled for editing. That is, in this second form I will only add more information to the same record that was added by the first form:
The problem is that when I click the "Save" button on the second form, it does not save the new data entered in the second form in the database.
Class CadernosCadastrados.
@Entity public class CadernosCadastrados implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private Long numeroID;
private String numeroCaderno;
private String cras;
private String dataRecebido;
private String recebidoPor;
private String avaliadoPor;
@Column(length = 2000)
private String observacoes;
private String codigoFamiliar;
private String nis;
private String data;
private String cpf;
private String rg;
private String ctps;
private String caixa;
private String cadernos;
private String certidaoNascimento;
private String fichaExclusao;
private String fichaAveriguacao;
private String suplementar;
private String suplementarDois;
private String entrevistador;
private String responsavelFamiliar;
private String pendenciaDocumentacao;
private String pendenciaFormulario;
private String pendenciaAssinatura;
public String status;
Change method that is triggered by clicking the "Save" button on the second form:
@RequestMapping("alterar")
public String alterar(CadernosCadastrados objeto, Long numeroID, Model model) {
List<CadernosCadastrados> cadernos = daoCadernosCadastrados.listar();
daoCadernosCadastrados.alterar(objeto);
//if(daoCadernosCadastrados.limpar(objeto )) {;
return "public/sucessos";
}
Method change in the DaoCadernoCadastrados class, which is called by the change method that I showed earlier:
public void alterar(CadernosCadastrados objeto) {
entityManager.merge(objeto);
}