I'm developing a system using Java, Maven, Hibernate, PrimeFaces and MySQL database. Within this system, I created a program to record the amount of rainfall that occurs on the day.
My table Pluviometro
has the fields for (auto increment code, location, date and amount of rain).
When I start the screen, I have a @PostContruct
that initializes my object Pluviometro
. After initialization, I fill in the 3 fields of the table and click on save.
Clicking the "save" button calls the method to save the data, but the Pluviometro
object arrives null
. Can anyone give me a hint of what might be going on?
@PostConstruct
private void startDeTela(){
PluviometroDAO pluviometroDAO = new PluviometroDAO();
pluviometros = pluviometroDAO.listar("dataDeApontamento");
pluviometro = new Pluviometro();
carregaSelectItens();
}
public void novo(){
pluviometro = new Pluviometro();
}
public void salvar(){
PluviometroDAO pluviometroDAO = new PluviometroDAO();
try{
pluviometroDAO.merge(pluviometro);
Messages.addGlobalInfo("Apontamento Registrado Com Sucesso.");
novo();
}catch(RuntimeException erro){
erro.printStackTrace();
}
}