2013-03-28 72 views
0

嘗試瀏覽到生成的JSF頁面時,發生以下錯誤。當使用REST(JAX-RS)來操縱或從數據庫中檢索信息,也會發生此確切的錯誤:Java EE:org.postgresql.util.PSQLException:列不存在,但它確實存在

Internal Exception: org.postgresql.util.PSQLException: ERROR: column "transkey" does not exist

然而,該柱確實存在,執行觸發從pgAdmin的該錯誤的確切查詢時,正常表被返回(SELECT translationid爲A1,郎爲A2,transkey爲A3,德蘭士瓦AS A4 FROM projectx.projectx.translation)

完整堆棧跟蹤:從數據庫中生成

WARNING: Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException 
Internal Exception: org.postgresql.util.PSQLException: ERROR: column "transkey" does not exist 
    Position: 41 
Error Code: 0 
Call: SELECT translationid AS a1, lang AS a2, transkey AS a3, transval AS a4 FROM projectx.projectx.translation LIMIT ? OFFSET ? 
    bind => [2 parameters bound] 
Query: ReadAllQuery(referenceClass=Translation sql="SELECT translationid AS a1, lang AS a2, transkey AS a3, transval AS a4 FROM projectx.projectx.translation LIMIT ? OFFSET ?") 
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333) 
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:644) 
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:535) 
    at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1717) 
    at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:566) 
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:207) 
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193) 
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:264) 
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:646) 
    at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2611) 
    at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2570) 
    at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:420) 
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1081) 
    at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:844) 
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1040) 
    at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:392) 
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1128) 
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2871) 
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1516) 
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1498) 
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1463) 
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:485) 
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:742) 
    at jsf.AbstractFacade.findRange(AbstractFacade.java:51) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:616) 
    at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052) 
    at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124) 
    at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5388) 
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619) 
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800) 
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571) 
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162) 
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:616) 
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861) 
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800) 
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370) 
    at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5360) 
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5348) 
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214) 
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:89) 
    at sun.proxy.$Proxy131.findRange(Unknown Source) 
    at jsf.__EJB31_Generated__TranslationFacade__Intf____Bean__.findRange(Unknown Source) 
    at jsf.TranslationController$1.createPageDataModel(TranslationController.java:57) 
    at jsf.TranslationController.getItems(TranslationController.java:157) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:616) 
    at javax.el.BeanELResolver.getValue(BeanELResolver.java:363) 
    at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) 
    at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) 
    at com.sun.el.parser.AstValue.getValue(AstValue.java:138) 
    at com.sun.el.parser.AstValue.getValue(AstValue.java:183) 
    at com.sun.el.parser.AstEqual.getValue(AstEqual.java:58) 
    at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:224) 
    at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) 
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194) 
    at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:413) 
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1751) 
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:168) 
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845) 
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757) 
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760) 
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760) 
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402) 
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) 
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) 
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) 
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) 
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) 
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) 
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) 
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161) 
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195) 
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860) 
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757) 
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056) 
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229) 
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) 
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) 
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) 
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) 
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) 
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) 
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71) 
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) 
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) 
    at java.lang.Thread.run(Thread.java:679) 

實體類:

@Entity 
@Table(name = "translation", catalog = "projectx", schema = "projectx") 
@XmlRootElement 
@NamedQueries({ 
    @NamedQuery(name = "Translation.findAll", query = "SELECT t FROM Translation t"), 
    @NamedQuery(name = "Translation.findByTranslationid", query = "SELECT t FROM Translation t WHERE t.translationid = :translationid"), 
    @NamedQuery(name = "Translation.findByLang", query = "SELECT t FROM Translation t WHERE t.lang = :lang"), 
    @NamedQuery(name = "Translation.findByKey", query = "SELECT t FROM Translation t WHERE t.transkey = :transkey"), 
    @NamedQuery(name = "Translation.findByVal", query = "SELECT t FROM Translation t WHERE t.transval = :transval")}) 
public class Translation implements Serializable { 
    private static final long serialVersionUID = 1L; 
    @Id 
    @Basic(optional = false) 
    @GeneratedValue(strategy = GenerationType.IDENTITY) 
    @Column(name = "translationid") 
    private Integer translationid; 
    @Size(max = 3) 
    @Column(name = "lang") 
    private String lang; 
    @Size(max = 1000) 
    @Column(name = "transkey") 
    private String transkey; 
    @Size(max = 1000) 
    @Column(name = "transval") 
    private String transval; 

    public Translation() { 
    } 

    public Translation(Integer translationid) { 
     this.translationid = translationid; 
    } 

    public Integer getTranslationid() { 
     return translationid; 
    } 

    public void setTranslationid(Integer translationid) { 
     this.translationid = translationid; 
    } 

    public String getLang() { 
     return lang; 
    } 

    public void setLang(String lang) { 
     this.lang = lang; 
    } 

    public String getKey() { 
     return transkey; 
    } 

    public void setKey(String transkey) { 
     this.transkey = transkey; 
    } 

    public String getVal() { 
     return transval; 
    } 

    public void setVal(String transval) { 
     this.transval = transval; 
    } 

    @Override 
    public int hashCode() { 
     int hash = 0; 
     hash += (translationid != null ? translationid.hashCode() : 0); 
     return hash; 
    } 

    @Override 
    public boolean equals(Object object) { 
     // TODO: Warning - this method won't work in the case the id fields are not set 
     if (!(object instanceof Translation)) { 
      return false; 
     } 
     Translation other = (Translation) object; 
     if ((this.translationid == null && other.translationid != null) || (this.translationid != null && !this.translationid.equals(other.translationid))) { 
      return false; 
     } 
     return true; 
    } 

    @Override 
    public String toString() { 
     return "model.Translation[ translationid=" + translationid + " ]"; 
    } 

} 

非常感謝您的回答。 :)

+0

請向我們展示CREATE TABLE語句。 –

回答

0

只是一個猜測:檢查你是否真的在數據庫中有transkey列。我看到你有一個名爲getKey()/ setKey()的transkey的getter/setter,也許這是誤導的數據庫模式生成器?

+0

我真的有這個專欄,但是把它從'key'改爲'transkey',因爲key是一個保留關鍵字。我會嘗試重新生成這個類,以便更新getter和setter,謝謝。 – Joey

+0

當試圖重新生成實體類時,我發現JDBC連接器已經損壞。最後設法通過刪除persistence.xml來修復問題,添加一個新的持久化單元並重新生成實體類。謝謝你 :) – Joey

0

一個問題:你使用「transKey」還是「transkey」作爲你的dababase字段的名稱?大寫字母在我的JPA應用程序中產生了錯誤。

相關問題