我在获取列表大小为500的hibernate查询时遇到错误 我得到的错误是 你能帮我解决这个错误的原因
[org.springframework.remoting.support.RemoteInvocationTraceInterceptor] (RMI TCP Connection(2)-192.168.43.183) Processing of RmiServiceExporter remote call resulted in fatal exception: com.elcy.service.LCMessageRmiService.sendReportEmail: java.lang.StackOverflowError
at java.lang.reflect.Constructor.newInstance(Unknown Source) [rt.jar:1.8.0_25]
at java.lang.Class.newInstance(Unknown Source) [rt.jar:1.8.0_25]
at org.hibernate.hql.internal.ast.SqlASTFactory.create(SqlASTFactory.java:260) [hibernate-core-4.3.2.Final.jar:4.3.2.Final]
at antlr.ASTFactory.create(ASTFactory.java:153) [antlr-2.7.7.jar:]
at antlr.ASTFactory.create(ASTFactory.java:186) [antlr-2.7.7.jar:]
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2038) [hibernate-core-4.3.2.Final.jar:4.3.2.Final]
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2046) [hibernate-core-4.3.2.Final.jar:4.3.2.Final]
ERROR [org.jboss.as.ejb3.invocation] (Thread-226 (ActiveMQ-client-global-threads-225168338)) WFLYEJB0034: EJB Invocation failed on component LCMessageMDB for method public void com.elcy.message.LCMessageMDB.onMessage(javax.jms.Message): javax.ejb.EJBTransactionRolledbackException: WFLYEJB0457: Unexpected Error
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:153) [wildfly-ejb3-10.0.0.Final.jar:10.0.0.Final]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:256) [wildfly-ejb3-10.0.0.Final.jar:10.0.0.Final]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:329) [wildfly-ejb3-10.0.0.Final.jar:10.0.0.Final]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.8.0_25]`
`java.lang.Thread.run(未知来源)[rt.jar:1.8.0_25]
Caused by: java.lang.StackOverflowError
at java.lang.reflect.Constructor.newInstance(Unknown Source) [rt.jar:1.8.0_25]
at java.lang.Class.newInstance(Unknown Source) [rt.jar:1.8.0_25]
at org.hibernate.hql.internal.ast.SqlASTFactory.create(SqlASTFactory.java:260)
at antlr.ASTFactory.create(ASTFactory.java:153)
at antlr.ASTFactory.create(ASTFactory.java:186)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2038)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2046)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2046)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2046)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2046)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2046)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2046)
my hql query code looks like as given below
for (Iterator iterator = resultList.iterator(); iterator.hasNext(); ) {
String id = (String) iterator.next();
if (iterator.hasNext())
sqlQueryBuff.append(" t.id = '" + id + "' OR");
else
sqlQueryBuff.append(" t.id = '" + id + "' ) ");
}
query = session.createQuery(sqlQueryBuff.toString());
在这一行后我得到了这个完整的错误
我的maven依赖关系如下所示
<properties>
<jdk.version>1.6</jdk.version>
<spring-framework.version>4.0.2.RELEASE</spring-framework.version>
<hibernate.version>4.3.2.Final</hibernate.version>
<junit.version>4.11</junit.version>
<log.version>1.2.14</log.version>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
请建议我如何解决这个问题 感谢
答案 0 :(得分:0)
您创建复杂的HQL表达式。我建议使用“in”代替“=”和“或”
的长列表