While trying to browse to a generated JSF page, the following error occurs. This exact error also occurs when using REST (Jax-RS) to manipulate or retrieve info from the database:
当试图浏览到生成的JSF页面时,会发生以下错误。当使用REST (Jax-RS)来操作或检索数据库中的信息时,也会发生这样的错误:
Internal Exception: org.postgresql.util.PSQLException: ERROR: column "transkey" does not exist
内部异常:org.postgresql.util。PSQLException: ERROR: column“transkey”不存在。
However, this column does exist, when executing the exact query that triggers the error from pgAdmin, a normal table is returned (SELECT translationid AS a1, lang AS a2, transkey AS a3, transval AS a4 FROM projectx.projectx.translation)
但是,当执行触发pgAdmin错误的精确查询时,将返回一个正常的表(选择translationid为a1, lang为a2, transkey为a3,从projectx.projectx.translation)转换为a4。
Full stacktrace:
加:
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)
the entity class as generated from database:
从数据库生成的实体类:
@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 + " ]";
}
}
Very greatful for your answer(s). :)
非常感谢你的回答。:)
2 个解决方案
#1
0
Just a guess: check if you really have transkey column in database. I see that you have a getter/setter for transkey named getKey()/setKey(), maybe that misled db schema generator?
只是一个猜测:检查是否真的有数据库中的transkey列。我看到您有一个名为getKey()/setKey()的transkey的getter/setter,可能是误导了db模式生成器?
#2
0
One question: are you using "transKey" or "transkey" as the name of your dababase's field? The uppercase generated the error in my JPA application.
有一个问题:您是否使用“transKey”或“transKey”作为您的dababase字段的名称?大写字母生成了我的JPA应用程序中的错误。
#1
0
Just a guess: check if you really have transkey column in database. I see that you have a getter/setter for transkey named getKey()/setKey(), maybe that misled db schema generator?
只是一个猜测:检查是否真的有数据库中的transkey列。我看到您有一个名为getKey()/setKey()的transkey的getter/setter,可能是误导了db模式生成器?
#2
0
One question: are you using "transKey" or "transkey" as the name of your dababase's field? The uppercase generated the error in my JPA application.
有一个问题:您是否使用“transKey”或“transKey”作为您的dababase字段的名称?大写字母生成了我的JPA应用程序中的错误。