这是Hibernate HQL:
public Collection findByForeignKey(Long oidInfoComplementaria) throws DataAccessException {
return getHibernateTemplate().find("from CadInfoComplementaria cadInfoCompl where cadInfoCompl.entidadInfoComplementaria.oid = ?" , new Object[]{oidInfoComplementaria});
}
这些都是实体:
@Entity
@Table(name="PRDTABCADINFOCOMPLEMENTARIA")
public class CadInfoComplementaria implements BaseObject, Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private Long oid;
private EntidadInfoComplementaria entidadInfoComplementaria;
private Date fechaCaducidad;
public CadInfoComplementaria () {
}
@Id
@GeneratedValue(strategy=GenerationType.AUTO, generator="cadInfoComplementariaSequence")
@SequenceGenerator(name="cadInfoComplementariaSequence",sequenceName="SEQ_CADINFOCOMPLEMENTARIA")
@Column(name="OID", unique=true, nullable=false)
public Long getOid() {
return oid;
}
public void setOid(Long oid) {
this.oid = oid;
}
public void setOid(String _tmp){
oid = formatLong(_tmp);
}
private Long formatLong(String _tmp){
if(_tmp == null || _tmp.length() == 0) return null;
return new Long(_tmp);
}
@OneToOne
@JoinColumn(name="OID_INFOCOMPLEMENTARIA")
public EntidadInfoComplementaria getEntidadInfoComplementaria() {
return this.entidadInfoComplementaria;
}
public void setEntidadInfoComplementaria(EntidadInfoComplementaria entidadInfoComplementaria) {
this.entidadInfoComplementaria = entidadInfoComplementaria;
}
@Column(name="FECHA_CADUCIDAD", nullable=false)
public Date getFechaCaducidad() {
return fechaCaducidad;
}
public void setFechaCaducidad(Date fechaCaducidad) {
this.fechaCaducidad = fechaCaducidad;
}
}
@Entity
@Table(name="PRDTABENTIDAD_INFCOMPL")
public class EntidadInfoComplementaria implements BaseObject, Serializable {
private Long oid;
private Long oidEntidad;
private TxtInfoComplementaria txtInfoComplementaria;
private String texto;
private String flagEditado;
private String codEstado;
private String orden;
private Set variables;
private String codUsuarioAlta;
private String codUsuarioModi;
private String codOrigen;
private String codFuente;
private String codIdNFuente;
private Date fecFuente;
private Date fecAlta;
private Date oca;
private Long vsn;
public EntidadInfoComplementaria() {
}
@Id
@GeneratedValue(strategy=GenerationType.AUTO, generator="entidadInfoComplementariaSequence")
@SequenceGenerator(name="entidadInfoComplementariaSequence",sequenceName="SEQ_ENTINFOCOMPLEMENTARIA")
@Column(name="OID", unique=true, nullable=false)
public Long getOid() {
return this.oid;
}
public void setOid(Long oid) {
this.oid = oid;
...
}
以下是程序的例外情况:
org.springframework.orm.hibernate3.HibernateQueryException: in expected: cadInfoCompl [from CadInfoComplementaria cadInfoCompl where cadInfoCompl.entidadInfoComplementaria.oid = ?]; nested exception is org.hibernate.QueryException: in expected: cadInfoCompl [from CadInfoComplementaria cadInfoCompl where cadInfoCompl.entidadInfoComplementaria.oid = ?]
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:642)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:917)
at informa.app.aig.produccion.dao.hibernate.CadInfoComplementariaDAOHibernate.findByForeignKey(CadInfoComplementariaDAOHibernate.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:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy84.findByForeignKey(Unknown Source)
at informa.app.aig.produccion.service.CadInfoComplementariaSBeanImpl.obtenerCadInfoComplementariaClaveExtranjera(CadInfoComplementariaSBeanImpl.java:58)
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:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy85.obtenerCadInfoComplementariaClaveExtranjera(Unknown Source)
at informa.app.aig.vista.acciones.InformaActionAIG.obtenerInfComplementaria(InformaActionAIG.java:393)
at informa.app.aig.vista.acciones.InformaActionAIG.obtenerInfComplementaria(InformaActionAIG.java:346)
at informa.app.aig.produccion.vista.acciones.SeleccionInformacionComplementariaEmpresaAction.mostrarDatos(SeleccionInformacionComplementariaEmpresaAction.java:323)
at informa.app.aig.produccion.vista.acciones.SeleccionInformacionComplementariaEmpresaAction.realizarAccion(SeleccionInformacionComplementariaEmpresaAction.java:266)
at informa.arq.core.web.struts.action.InformaAction.execute(InformaAction.java:116)
at informa.app.produccion.core.web.InformaActionMigracion.execute(InformaActionMigracion.java:117)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:704)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:474)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:409)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1062)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:318)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:704)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:474)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:409)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1062)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:318)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.hibernate.QueryException: in expected: cadInfoCompl [from CadInfoComplementaria cadInfoCompl where cadInfoCompl.entidadInfoComplementaria.oid = ?]
at org.hibernate.hql.classic.FromParser.token(FromParser.java:106)
at org.hibernate.hql.classic.ClauseParser.token(ClauseParser.java:86)
at org.hibernate.hql.classic.PreprocessingParser.token(PreprocessingParser.java:108)
at org.hibernate.hql.classic.ParserHelper.parse(ParserHelper.java:28)
at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:216)
at org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:185)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:919)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
... 96 more
我找不到错误在哪里。 HQL是在一个DAO类中编写的,该类从一个接口扩展而来,该接口也是由一个接口调用的服务类扩展而来的。
有什么想法吗?
非常感谢你的帮助!
答案 0 :(得分:0)
问题解决了。我想,问题是Hibernate实体不在hibernate xml配置文件中。