Hello,
I'm trying to insert a register in my database MySQL, using Hibernate Annotations.
I'm using this class:
@Entity @Table(name="grupo") public class Grupo { private int codGrupo; private String descricao; @Column(name="descricao",nullable=false,unique=true) public String getDescricao() { return this.descricao; } public void setDescricao(String descricao) { this.descricao = descricao; } @Id(generate=GeneratorType.NONE) @Column(name="codgrupo") public int getCodGrupo() { return codGrupo; } public void setCodGrupo(int codGrupo) { this.codGrupo = codGrupo; } }
and this code in my Unit Test:
public void testInserir(){ Grupo g = new Grupo(); g.setCodGrupo(1); g.setBanco("teste"); this.facade.inserir(g); }
and the "inserir" method in facade use: getHibernateTemplate().save(g);
*** I'm using Hibernate+Spring
The register doesn't record in my database.
But, when I use @Id(generate=GeneratorType.IDENTITY), the register is recorded.
Somebody know as to decide this?
Thanks.
_________________ Breno Barros
Software Engineer
|