E ai galera do fórum, estou com um problema na hora de conseguir retirar os dados do banco de dados. Estou utilizando MySQL e JPA2.0 com hibernate4
Tenho uma tabela que representa um objeto
@Entity
@Table(name="cesta")
public class Cesta implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(unique=true, nullable=false)
private int idCesta;
@Lob()
@Column(nullable=false)
private String descricao;
@Column(nullable=false, length=45)
private String identificador;
@Column(nullable=false, length=45)
private String idioma;
@Column(nullable=false, length=50)
private String nome;
@Lob()
@Column(nullable=false)
private String palavraChave;
@Lob()
@Column(nullable=false)
private String url;
//bi-directional many-to-one association to Alunocesta
@OneToMany(mappedBy="cesta")
private List<Alunocesta> alunocestas;
//bi-directional many-to-one association to Categoriadireito
@OneToMany(mappedBy="cesta")
private List<Categoriadireito> categoriadireitos;
//bi-directional many-to-one association to Categoriaeducacional
@OneToMany(mappedBy="cesta")
private List<Categoriaeducacional> categoriaeducacionals;
//bi-directional many-to-one association to Categoriatecnica
@OneToMany(mappedBy="cesta")
private List<Categoriatecnica> categoriatecnicas;
//bi-directional many-to-one association to Categoriavida
@OneToMany(mappedBy="cesta")
private List<Categoriavida> categoriavidas;
//bi-directional many-to-one association to Cestacha
@OneToMany(mappedBy="cesta")
private List<Cestacha> cestachas;
//bi-directional many-to-one association to Recomendado
@OneToMany(mappedBy="cesta")
private List<Recomendado> recomendados;
public Cesta() {
}
public int getIdCesta() {
return this.idCesta;
}
public void setIdCesta(int idCesta) {
this.idCesta = idCesta;
}
// GETTERS E SETTERS
}
E tenho a tabela com outros atributos ligados a essa tabela atraves de uma chave
@Entity
@Table(name="cestacha")
public class Cestacha implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(unique=true, nullable=false)
private int idCestaCha;
@Column(nullable=false, length=45)
private String atitude;
@Column(nullable=false, length=45)
private String conhecimento;
@Column(nullable=false, length=45)
private String habilidade;
@Column(nullable=false, length=45)
private String nomeCompetencia;
//bi-directional many-to-one association to Cesta
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="Cesta_idCesta", nullable=false)
private Cesta cesta; // AQUI EU NAO CONSIGO RECUPERAR O ID
public Cestacha() {
}
public int getIdCestaCha() {
return this.idCestaCha;
}
public void setIdCestaCha(int idCestaCha) {
this.idCestaCha = idCestaCha;
}
public String getAtitude() {
return this.atitude;
}
public void setAtitude(String atitude) {
this.atitude = atitude;
}
public String getConhecimento() {
return this.conhecimento;
}
public void setConhecimento(String conhecimento) {
this.conhecimento = conhecimento;
}
public String getHabilidade() {
return this.habilidade;
}
public void setHabilidade(String habilidade) {
this.habilidade = habilidade;
}
public String getNomeCompetencia() {
return this.nomeCompetencia;
}
public void setNomeCompetencia(String nomeCompetencia) {
this.nomeCompetencia = nomeCompetencia;
}
public Cesta getCesta() {
return this.cesta;
}
public void setCesta(Cesta cesta) {
this.cesta = cesta;
}
}
Durante a execução do programa necessito carregar a tabela “cestacha”, até ai tudo bem, mas logo necessito recuperar o objeto cesta, o qual a tabela cesta faz referencia e nao consigo, ele acusa o seguinte erro
Exception in thread "main" org.hibernate.service.UnknownServiceException: Unknown service requested [org.hibernate.event.service.spi.EventListenerRegistry]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:126)
at org.hibernate.internal.SessionImpl.eventListenerGroup(SessionImpl.java:624)
at org.hibernate.internal.SessionImpl.listeners(SessionImpl.java:620)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:953)
at org.hibernate.internal.SessionImpl.immediateLoad(SessionImpl.java:891)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:158)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:195)
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:185)
at entidade.Cesta_$$_javassist_5.getIdCesta(Cesta_$$_javassist_5.java)
at teste.Main.main(Main.java:137)
alguem saberia o que esta acontecendo???