Boa noite,
Ja configurei o Hibernate, agora preciso criar um método, para salvar os dados inseridos no formulário no BD. Ja procurei um modelo mas não consigo. Tenho o hibernateutil:
package br.com.divulgando.s21_projweb2011.g289.Conn;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.SessionFactory;
/**
-
Hibernate Utility class with a convenient method to get Session Factory object.
-
@author Administrador
*/
public class HibernateUtil {private static final SessionFactory sessionFactory;
static { try { // Create the SessionFactory from standard (hibernate.cfg.xml) // config file. sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory(); } catch (Throwable ex) { // Log the exception. System.err.println(“Initial SessionFactory creation failed.” + ex); throw new ExceptionInInitializerError(ex); } }
public static SessionFactory getSessionFactory() { return sessionFactory; } }
[size=18]Mapeamento do Hibernate e pojos[/size]
package br.com.divulgando.s21_projweb2011.g289.Conn;
// Generated 18/11/2011 14:59:59 by Hibernate Tools 3.2.1.GA
/**
-
Cadastro generated by hbm2java
*/
public class Cadastro implements java.io.Serializable {private Integer id; private String email; private String nomeRem; private String cellRem; private String assinatura; private String senha;
public Cadastro() {
}public Cadastro(String email, String nomeRem, String cellRem, String senha) { this.email = email; this.nomeRem = nomeRem; this.cellRem = cellRem; this.senha = senha; } public Cadastro(String email, String nomeRem, String cellRem, String assinatura, String senha) { this.email = email; this.nomeRem = nomeRem; this.cellRem = cellRem; this.assinatura = assinatura; this.senha = senha; }
public Integer getId() { return this.id; }
public void setId(Integer id) { this.id = id; } public String getEmail() { return this.email; }
public void setEmail(String email) { this.email = email; } public String getNomeRem() { return this.nomeRem; }
public void setNomeRem(String nomeRem) { this.nomeRem = nomeRem; } public String getCellRem() { return this.cellRem; }
public void setCellRem(String cellRem) { this.cellRem = cellRem; } public String getAssinatura() { return this.assinatura; }
public void setAssinatura(String assinatura) { this.assinatura = assinatura; } public String getSenha() { return this.senha; }
public void setSenha(String senha) {
this.senha = senha;
Mas não sei quais parâmetros para criar o método para salvar no bd, alguém pode me passar um modelo?