Pessoal.
Não estou sabendo fazer uma ligação n:n no hibernate, peço por favor que me ajudem caso possível.
A ideia é ligar Publicacao (que é uma tabela que herda de Pagina) a Categoria atraves da PaginaCategoria.
Mensagem de erro:
Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
org.jboss.seam.InstantiationException: Could not instantiate Seam component: hibernateSessionFactory
at org.jboss.seam.Component.newInstance(Component.java:2106)
at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:112)
at org.jboss.seam.init.Initialization.init(Initialization.java:735)
at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:35)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: br.bel.Categoria.publicacoesCategoria[br.bel.Publicacao]
Categoria
public class Categoria implements java.io.Serializable {
@Id
@GeneratedValue
@Column(name="idcategoria")
private int sequencialCategoria;
@Column(name="txnomeCategoria", nullable=false, unique=true)
private String categoria;
@Column(name="txdescricaoCategoria")
private String descricao;
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE},
mappedBy = "categoriasPublicacao",
targetEntity = Publicacao.class)
private List<Publicacao> publicacoesCategoria;
...
}
Publicacoes
public class Publicacao extends Pagina{
@ManyToOne(fetch=FetchType.LAZY)
@Column(name="idnivelaluno")
private NivelAluno nivelPublicacao;
@ManyToMany(targetEntity=Categoria.class,
cascade={CascadeType.PERSIST, CascadeType.MERGE})
@JoinTable( name="Categoriapagina",
joinColumns=@JoinColumn(name="idpagina"),
inverseJoinColumns=@JoinColumn(name="idcategoria"))
private List<Categoria> categoriasPublicacao;
...