【发布时间】:2014-10-08 05:19:21
【问题描述】:
我收到下面的错误,说有堆栈溢出。发生这种情况是因为带有 IN (id, id, id...id) 的 sql 语句有大量参数。有没有什么办法解决这一问题?这发生在我使用 Eclipse 的本地环境中。
JPA
@Query(value="SELECT p FROM PendingCourseRegistration p WHERE p.sisId IN ?1 AND p.testId = ?2")
List<PendingCourseRegistration> findPendingCourseRegistrationInSisIdsAndTestId(List<String> sisIds, Long testID);
错误
java.lang.StackOverflowError: null
at java.lang.Abstract witingBuilder.append(AbstractStringBuilder.java:416) ~[na:1.7.0_17]
at java.lang.StringBuffer.append(StringBuffer.java:237) ~[na:1.7.0_17]
at antlr.BaseAST.toStringList(BaseAST.java:341) ~[antlr-2.7.7.jar:na]
at antlr.BaseAST.toStringList(BaseAST.java:347) ~[antlr-2.7.7.jar:na]
at antlr.BaseAST.toStringList(BaseAST.java:347) ~[antlr-2.7.7.jar:na]
at antlr.BaseAST.toStringList(BaseAST.java:347) ~[antlr-2.7.7.jar:na]
休眠查询
2:26.763 [ocPifScheduler-1] DEBUG o.s.o.j.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler - Creating new EntityManager for shared EntityManager invocation
09:52:26.788 [Scheduler-1] DEBUG org.hibernate.hql.internal.ast.QueryTranslatorImpl - parse() - HQL: SELECT p FROM com.test.PendingCourseRegistration p WHERE p.sisId IN (:x10_, :x11_, :x12_, :x13_, :x14_, :x15_, :x16_, :x17_, :x18_, :x19_, :x110_, :x111_, :x112_, :x113_, :x114_, :x115_, :x116_, :x117_, :x118_, :x119_, ...:xN) AND p.id = ?2
09:52:26.891 [Scheduler-1] DEBUG org.hibernate.hql.internal.ast.QueryTranslatorImpl - --- HQL AST ---
\-[QUERY] Node: 'query'
+-[SELECT_FROM] Node: 'SELECT_FROM'
| +-[FROM] Node: 'FROM'
| | \-[RANGE] Node: 'RANGE'
| | +-[DOT] Node: '.'
| | | +-[DOT] Node: '.'
| | | | +-[DOT] Node: '.'
| | | | | +-[DOT] Node: '.'
| | | | | | +-[DOT] Node: '.'
| | | | | | | +-[DOT] Node: '.'
| | | | | | | | +-[IDENT] Node: 'com'
| | | | \-[IDENT] Node: 'model'
| | | \-[IDENT] Node: 'PendingCourseRegistration'
| | \-[ALIAS] Node: 'p'
| \-[SELECT] Node: 'SELECT'
| \-[IDENT] Node: 'p'
\-[WHERE] Node: 'WHERE'
\-[AND] Node: 'AND'
+-[IN] Node: 'in'
| +-[DOT] Node: '.'
| | +-[IDENT] Node: 'p'
| | \-[IDENT] Node: 'sisId'
| \-[IN_LIST] Node: 'inList'
| +-[COLON] Node: ':'
| | \-[IDENT] Node: 'x10_'
| +-[COLON] Node: ':'
| | \-[IDENT] Node: 'x11_'
| +-[COLON] Node: ':'
| | \-[IDENT] Node: 'x12_'
| +-[COLON] Node: ':'
| | \-[IDENT] Node: 'x13_'
| +-[COLON] Node: ':'
| | \-[IDENT] Node: 'x14_'
| +-[COLON] Node: ':'
| | \-[IDENT] Node: 'x15_'
| +-[COLON] Node: ':'
| | \-[IDENT] Node: 'x16_'
| +-[COLON] Node: ':'
| | \-[IDENT] Node: 'x17_'
【问题讨论】:
-
你有哪个版本的hibernate?
-
4.1.12.Final 是我们正在使用的版本。
标签: java mysql sql hibernate stack-overflow