Boa tarde pessoal,
Estou com o seguinte “probleminha”, não estou conseguindo fazer o relacionamento entre 2 tabelas.
Produtos e Autores.
@Entity
public class Produto {
@Id
@GeneratedValue
private Long id;
//Outros atributos...
@ManyToOne
@JoinColumn(name = "autor", referencedColumnName = "id")
private Autor autor;
//Getter's e Setter's
@Entity
public class Autor {
@Id
@GeneratedValue
private Long id;
//Outros atributos...
//Getter's e Setter's
me dá o seguinte erro ao executar…
exception
javax.servlet.ServletException
javax.faces.webapp.FacesServlet.service(FacesServlet.java:325)
root cause
java.lang.ExceptionInInitializerError
br.com.loja.dao.Dao.<init>(Dao.java:23)
br.com.loja.mb.ProdutoBean.getProdutos(ProdutoBean.java:33)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
javax.el.BeanELResolver.getValue(BeanELResolver.java:87)
com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
org.apache.el.parser.AstValue.getValue(AstValue.java:169)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:193)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:181)
javax.faces.component.UIData.getValue(UIData.java:557)
javax.faces.component.UIData.getDataModel(UIData.java:1297)
javax.faces.component.UIData.getRowCount(UIData.java:342)
org.primefaces.component.datatable.DataTable.calculatePage(DataTable.java:769)
org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:160)
org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:85)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:883)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1659)
javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:853)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1652)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:399)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
root cause
org.hibernate.AnnotationException: @OneToOne or @ManyToOne on br.com.loja.modelo.Produto.autor references an unknown entity: br.com.loja.modelo.Autor
org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:107)
org.hibernate.cfg.Configuration.processEndOfQueue(Configuration.java:1580)
org.hibernate.cfg.Configuration.processFkSecondPassInOrder(Configuration.java:1503)
org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1419)
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856)
br.com.loja.util.HibernateUtil.<clinit>(HibernateUtil.java:16)
br.com.loja.dao.Dao.<init>(Dao.java:23)
br.com.loja.mb.ProdutoBean.getProdutos(ProdutoBean.java:33)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
javax.el.BeanELResolver.getValue(BeanELResolver.java:87)
com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
org.apache.el.parser.AstValue.getValue(AstValue.java:169)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:193)
javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:181)
javax.faces.component.UIData.getValue(UIData.java:557)
javax.faces.component.UIData.getDataModel(UIData.java:1297)
javax.faces.component.UIData.getRowCount(UIData.java:342)
org.primefaces.component.datatable.DataTable.calculatePage(DataTable.java:769)
org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:160)
org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:85)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:883)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1659)
javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:853)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1652)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:399)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)