源码
private List<SettleList_bak> querySettleList(final String branchID, final String settleMasterID, final String customerBkAcctID, final String issuedDate, SettleListPageBean settleListPageBean) {
final int firstResult = settleListPageBean.getStartNum();
final int maxResult = settleListPageBean.getPageSize();
final int currentPage = settleListPageBean.getCurrentPage();
final int totalPages = settleListPageBean.getTotalPages();
final int totalRows = settleListPageBean.getTotalRows();

List<SettleList_bak> settleList_baks = template.executeFind(new JpaCallback(){ public Object doInJpa(EntityManager em)
throws PersistenceException {
// TODO Auto-generated method stub
Query query = em.createNativeQuery("{call settleList (?, ?, ?, ?)}");
query.setParameter(1, branchID);
query.setParameter(2, settleMasterID);
query.setParameter(3, customerBkAcctID);
query.setParameter(4, issuedDate);
query.setFirstResult(firstResult);
query.setMaxResults(maxResult);
List list = query.getResultList(); --------------- 533行
return list;
} });
return settleList_baks;
}异常:
Exception in thread "main" org.springframework.orm.jpa.JpaSystemException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:630)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:75)
at com.sanfang.fastway2009.dao.implement.SettleChargeQueryDAOImpl$3.doInJpa(SettleChargeQueryDAOImpl.java:533)
at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:185)
at org.springframework.orm.jpa.JpaTemplate.executeFind(JpaTemplate.java:152)
at com.sanfang.fastway2009.dao.implement.SettleChargeQueryDAOImpl.querySettleList(SettleChargeQueryDAOImpl.java:521)
at com.sanfang.fastway2009.dao.implement.SettleChargeQueryDAOImpl.querySettleList(SettleChargeQueryDAOImpl.java:501)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
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 $Proxy85.querySettleList(Unknown Source)
at com.sanfang.fastway2009.business.settle.implement.SettleBusinessImpl.querySettleList(SettleBusinessImpl.java:156)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
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 $Proxy87.querySettleList(Unknown Source)
at com.sanfang.fastway2009.test.Test.main(Test.java:81)
Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2223)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:66)
... 29 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: '{' 附近有语法错误。
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.sendExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteQuery(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(Unknown Source)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
... 36 more