Pessoal estou tendo problema com auto sequence na minha pk, criei um campo id como pk e um sequence para ele, na mão funciona, mas quando uso o hibernate me da erro, ele não gera uma aouto sequencia para o id, da erro de violação de unique key da pk, como resolvo isto? que configuração faço? estou usando annotation no hibernate.
minha classe:
[code]package br.com.maringa.requisicao.interno.pojo;
// Generated 15/08/2006 15:45:52 by Hibernate Tools 3.1.0.beta5
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
/**
-
Usuariorequisicao generated by hbm2java
*/
@Entity
@Table(name = "usuariorequisicao", schema = "requisicao", uniqueConstraints = {})
public class Usuariorequisicao implements java.io.Serializable {// Fields
private long id;
private Perfil perfil;
private Clienteportal clienteportal;
private String nome;
private String tel;
private String cel;
private String email;
private Date datacad;
private boolean ativo;
private short sexo;
private Date dataedit;
private Date horaedit;
private Long iduseredit;
private Long idusereditagn;
private Set<UsuarioCentrocusto> usuarioCentrocustos = new HashSet<UsuarioCentrocusto>(
0);private Set<Outro> outros = new HashSet<Outro>(0);
private Set<Solicitacao> solicitacaosForIdpax = new HashSet<Solicitacao>(0);
private Set<Solicitacao> solicitacaosForIdsol = new HashSet<Solicitacao>(0);
private Set<Hotel> hotels = new HashSet<Hotel>(0);
private Set<Carro> carros = new HashSet<Carro>(0);
private Set<Aereo> aereos = new HashSet<Aereo>(0);
private Set<Usuario> usuarios = new HashSet<Usuario>(0);
// Constructors
/** default constructor */
public Usuariorequisicao() {
}/** minimal constructor */
public Usuariorequisicao(long id, Perfil perfil,
Clienteportal clienteportal, String nome, String email,
Date datacad, boolean ativo, short sexo) {
this.id = id;
this.perfil = perfil;
this.clienteportal = clienteportal;
this.nome = nome;
this.email = email;
this.datacad = datacad;
this.ativo = ativo;
this.sexo = sexo;
}/** full constructor */
public Usuariorequisicao(long id, Perfil perfil,
Clienteportal clienteportal, String nome, String tel, String cel,
String email, Date datacad, boolean ativo, short sexo,
Date dataedit, Date horaedit, Long iduseredit, Long idusereditagn,
Set<UsuarioCentrocusto> usuarioCentrocustos, Set<Outro> outros,
Set<Solicitacao> solicitacaosForIdpax,
Set<Solicitacao> solicitacaosForIdsol, Set<Hotel> hotels,
Set<Carro> carros, Set<Aereo> aereos, Set<Usuario> usuarios) {
this.id = id;
this.perfil = perfil;
this.clienteportal = clienteportal;
this.nome = nome;
this.tel = tel;
this.cel = cel;
this.email = email;
this.datacad = datacad;
this.ativo = ativo;
this.sexo = sexo;
this.dataedit = dataedit;
this.horaedit = horaedit;
this.iduseredit = iduseredit;
this.idusereditagn = idusereditagn;
this.usuarioCentrocustos = usuarioCentrocustos;
this.outros = outros;
this.solicitacaosForIdpax = solicitacaosForIdpax;
this.solicitacaosForIdsol = solicitacaosForIdsol;
this.hotels = hotels;
this.carros = carros;
this.aereos = aereos;
this.usuarios = usuarios;
}// Property accessors
@Id
@Column(name = "id", unique = true, nullable = false, insertable = true, updatable = true)
public long getId() {
return this.id;
}public void setId(long id) {
this.id = id;
}@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
@JoinColumn(name = "idperfil", unique = false, nullable = false, insertable = true, updatable = true)
public Perfil getPerfil() {
return this.perfil;
}public void setPerfil(Perfil perfil) {
this.perfil = perfil;
}@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
@JoinColumn(name = "idcliente", unique = false, nullable = false, insertable = true, updatable = true)
public Clienteportal getClienteportal() {
return this.clienteportal;
}public void setClienteportal(Clienteportal clienteportal) {
this.clienteportal = clienteportal;
}@Column(name = "nome", unique = false, nullable = false, insertable = true, updatable = true, length = 100)
public String getNome() {
return this.nome;
}public void setNome(String nome) {
this.nome = nome;
}@Column(name = "tel", unique = false, nullable = true, insertable = true, updatable = true, length = 12)
public String getTel() {
return this.tel;
}public void setTel(String tel) {
this.tel = tel;
}@Column(name = "cel", unique = false, nullable = true, insertable = true, updatable = true, length = 12)
public String getCel() {
return this.cel;
}public void setCel(String cel) {
this.cel = cel;
}@Column(name = "email", unique = false, nullable = false, insertable = true, updatable = true, length = 100)
public String getEmail() {
return this.email;
}public void setEmail(String email) {
this.email = email;
}@Temporal(TemporalType.DATE)
@Column(name = "datacad", unique = false, nullable = false, insertable = true, updatable = true, length = 13)
public Date getDatacad() {
return this.datacad;
}public void setDatacad(Date datacad) {
this.datacad = datacad;
}@Column(name = "ativo", unique = false, nullable = false, insertable = true, updatable = true)
public boolean isAtivo() {
return this.ativo;
}public void setAtivo(boolean ativo) {
this.ativo = ativo;
}@Column(name = "sexo", unique = false, nullable = false, insertable = true, updatable = true)
public short getSexo() {
return this.sexo;
}public void setSexo(short sexo) {
this.sexo = sexo;
}@Temporal(TemporalType.DATE)
@Column(name = "dataedit", unique = false, nullable = true, insertable = true, updatable = true, length = 13)
public Date getDataedit() {
return this.dataedit;
}public void setDataedit(Date dataedit) {
this.dataedit = dataedit;
}@Temporal(TemporalType.TIME)
@Column(name = "horaedit", unique = false, nullable = true, insertable = true, updatable = true, length = 8)
public Date getHoraedit() {
return this.horaedit;
}public void setHoraedit(Date horaedit) {
this.horaedit = horaedit;
}@Column(name = "iduseredit", unique = false, nullable = true, insertable = true, updatable = true)
public Long getIduseredit() {
return this.iduseredit;
}public void setIduseredit(Long iduseredit) {
this.iduseredit = iduseredit;
}@Column(name = "idusereditagn", unique = false, nullable = true, insertable = true, updatable = true)
public Long getIdusereditagn() {
return this.idusereditagn;
}public void setIdusereditagn(Long idusereditagn) {
this.idusereditagn = idusereditagn;
}@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "usuariorequisicao")
public Set<UsuarioCentrocusto> getUsuarioCentrocustos() {
return this.usuarioCentrocustos;
}public void setUsuarioCentrocustos(
Set<UsuarioCentrocusto> usuarioCentrocustos) {
this.usuarioCentrocustos = usuarioCentrocustos;
}@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "usuariorequisicao")
public Set<Outro> getOutros() {
return this.outros;
}public void setOutros(Set<Outro> outros) {
this.outros = outros;
}@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "usuariorequisicaoByIdpax")
public Set<Solicitacao> getSolicitacaosForIdpax() {
return this.solicitacaosForIdpax;
}public void setSolicitacaosForIdpax(Set<Solicitacao> solicitacaosForIdpax) {
this.solicitacaosForIdpax = solicitacaosForIdpax;
}@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "usuariorequisicaoByIdsol")
public Set<Solicitacao> getSolicitacaosForIdsol() {
return this.solicitacaosForIdsol;
}public void setSolicitacaosForIdsol(Set<Solicitacao> solicitacaosForIdsol) {
this.solicitacaosForIdsol = solicitacaosForIdsol;
}@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "usuariorequisicao")
public Set<Hotel> getHotels() {
return this.hotels;
}public void setHotels(Set<Hotel> hotels) {
this.hotels = hotels;
}@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "usuariorequisicao")
public Set<Carro> getCarros() {
return this.carros;
}public void setCarros(Set<Carro> carros) {
this.carros = carros;
}@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "usuariorequisicao")
public Set<Aereo> getAereos() {
return this.aereos;
}public void setAereos(Set<Aereo> aereos) {
this.aereos = aereos;
}@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "usuariorequisicao")
public Set<Usuario> getUsuarios() {
return this.usuarios;
}public void setUsuarios(Set<Usuario> usuarios) {
this.usuarios = usuarios;
}
}
[/code]