0
I have a Java Spring MVC application, with Hibernate and JPA and HTML interface.
I have two forms that depend on the Notebooks class and its attributes.
In the first form I enter the data of a new Notebook, saved in the database and a new ID is created for this record.
When I do a search, in the numeroID=44 case, the second form is displayed, which comes with some fields of the first form already filled, 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 on the "Save" button of the second form, it does not save the new data entered in the second form in the database.
Class Notebooks Registered.
@Entity public class Notebooks Documents 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;
Method change that is triggered by clicking the "Save" button of 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";
}
Change method in the Daocadernocanced class, which is called by the change method I showed earlier:
public void alterar(CadernosCadastrados objeto) {
entityManager.merge(objeto);
}
Adriano, so if this obejto.equals, I do it because I have an attribute in the Notebook class called "Status" it is like String, there is not be I pass it to Boolean, so this if, this List I do is to call the list of entered data, Already in the DAO I had to put this null, because as I put ID, no find he asked me to iniciliazar the only option was null, since I am not passing the parameter id, no change, because if I do not create a variable with id and not initialize it, no way is wrong, already the IF with id != null is to take out the nullpointer, got it.
– Dickinson