从休眠3升级到休眠4后,getHibernateTemplate.find()无法正常工作

时间:2019-01-16 21:48:45

标签: spring hibernate

我们最近将Springs从2.5升级到4.1,并将Hibernate 3升级到Hibernate 4

getHibernateTemplate()。find()引发异常

2019-01-16 15:53:07,678 INFO  [[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] org.hibernate.hql.internal.QueryTranslatorFactoryInitiator: HHH000397: Using ASTQueryTranslatorFactory
Hibernate: select processing0_.DEPT_DVSN_CD as DEPT_DVSN_CD1_55_0_, payownacti1_.ACTION_SID as ACTION_SID1_33_1_, processing0_.DEPT_DVSN_DESC_TX as DEPT_DVSN_DESC_TX2_55_0_, processing0_.EFCTV_DT as EFCTV_DT3_55_0_, processing0_.XPRTN_DT as XPRTN_DT4_55_0_, processing0_.ACTION_ID as ACTION_ID5_55_0_, (select D.DEPT_DVSN_LONG_NM from Payown.DEPT_DVSN_AVT D where D.DEPT_DVSN_CD=processing0_.DEPT_DVSN_CD) as formula2_0_, (SELECT processing0_.COUNT (*)  FROM payown.paybl_error_vrn_dtl dtl, payown.paybl_error_vrn_st_log LOG WHERE dtl.paybl_error_vrn_dtl_sid = LOG.paybl_error_vrn_dtl_sid AND dtl.dept_dvsn_cd = processing0_.DEPT_DVSN_CD AND LOG.st_typ_cd != 'R') as formula3_0_, payownacti1_.ACTION_TYP_CD as ACTION_TYP_CD2_33_1_, payownacti1_.ACTION_PERFORMED_BY as ACTION_PERFORMED_B3_33_1_, payownacti1_.ACTION_PERFORMED_DATE as ACTION_PERFORMED_D4_33_1_, payownacti1_.PAYBL_SID as PAYBL_SID5_33_1_, payownacti1_.SVR_NM as SVR_NM6_33_1_, (select (E.EMP_FIRST_NAME || ' ' ||E.EMP_LAST_NAME) from Payown.Employee E where E.EMP_LOGIN_ID=upper(substr(payownacti1_.ACTION_PERFORMED_BY,1,instr(payownacti1_.ACTION_PERFORMED_BY,'/')-1))) as formula4_1_ from PAYOWN.PRCSNG_GRP_AVT processing0_ inner join PAYOWN.PAYOWN_ACTION_LOG payownacti1_ on processing0_.ACTION_ID=payownacti1_.ACTION_SID order by processing0_.DEPT_DVSN_CD
2019-01-16 15:53:07,828 WARN  [[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] org.hibernate.engine.jdbc.spi.SqlExceptionHelper: SQL Error: 936, SQLState: 42000
2019-01-16 15:53:07,828 ERROR [[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] org.hibernate.engine.jdbc.spi.SqlExceptionHelper: ORA-00936: missing expression


org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
        at org.springframework.orm.hibernate4.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:146)
        at org.springframework.orm.hibernate4.HibernateTemplate.doExecute(HibernateTemplate.java:343)
        at org.springframework.orm.hibernate4.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:308)
        at org.springframework.orm.hibernate4.HibernateTemplate.find(HibernateTemplate.java:864)
        at ***.processingpayments.prcsnggrp.dao.impl.ProcessingGroupDaoImpl.findProcessingGroupsList(ProcessingGroupDaoImpl.java:26)
        at ***.bo.impl.ProcessingGroupBoImpl.findProcessingGroupsList(ProcessingGroupBoImpl.java:27)
        at ******.ProcessingGroupAction.view(ProcessingGroupAction.java:107)
        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.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
        at *******.util.SpectrumLookupDispatchAction.execute(SpectrumLookupDispatchAction.java:130)
        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
        at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.ja

1 个答案:

答案 0 :(得分:0)

如果您仔细查看控制台日志,则会看到以下两行:

2019-01-16 15:53:07,828 WARN  [[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] org.hibernate.engine.jdbc.spi.SqlExceptionHelper: SQL Error: 936, SQLState: 42000
2019-01-16 15:53:07,828 ERROR [[ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] org.hibernate.engine.jdbc.spi.SqlExceptionHelper: ORA-00936: missing expression

每行的末尾表示您的sql语法中缺少表达式。在Navicat中运行sql,您会收到错误消息。

count(*)之间有一个空格,只需将其删除即可。