gpt4 book ai didi

Hibernate 错误 : current transaction is aborted, 命令被忽略,直到事务 block 结束

转载 作者:行者123 更新时间:2023-11-29 11:31:30 26 4
gpt4 key购买 nike

我在 catalina.out 日志中随机看到相同的错误:

WARNING: SQL Error: 0, SQLState: 25P02
Sep 8, 2010 11:50:13 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: ERROR: current transaction is aborted, commands ignored until end of transaction block
org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
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.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at PersistanceHelper.getTranslationByName(PersistanceHelper.java:174)
at SearchBean.getObject(SearchBean.java:146)
at org.apache.jsp.ajax.get_005fobject_jsp._jspService(get_005fobject_jsp.java:72)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1592)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1327)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:192)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:451)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:350)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:254)
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)

我不知道这个问题的原因是什么,因为我随机得到它并且通常查询工作正常。 m 使用 Postgresql 8.3,应用程序在 JSF 2.0 中。有没有人处理过这样的错误?是什么原因?感谢您的任何建议。

我需要补充一点,我只是从数据库中读取数据,但不会在这些查询中更新或插入任何数据。

--------------------------------编辑------------ --------------------------这是一个示例查询:

List object = null; 
try {
org.hibernate.Transaction tx = session.beginTransaction();
Query q = session.createQuery("from Table where lower(translatedText) like lower('%" + term + "%') or lower(translatedAscii) like lower('%" + term + "%') or lower(originalAscii) like lower('%" + term + "%')");
object = (List<Table>) q.list();
} catch (Exception e)
{ e.printStackTrace(); }
return object; }

我刚刚在 tomcat 日志中注意到了这一点:

Initial SessionFactory creation failed.java.lang.OutOfMemoryError: PermGen space

会不会是这个原因?如果我刷新应用程序,它往往会正常工作一段时间。

最好的问候,萨斯。

最佳答案

这可能意味着您的某些查询未执行。如果您在交易中有很多查询,例如

  • 开始交易
  • 查询1
  • 查询2
  • 查询3
  • 完成交易

并且 query2 抛出错误,然后当您尝试执行 query3 时,您会收到此错误。

  • 开始交易
  • 查询 1(成功)
  • query2(错误,出了点问题)
  • query3(抛出类似你的异常)
  • 完成交易

您应该处理从 query2 抛出的异常并处理它。向用户显示一些错误,回滚事务,永远不要尝试执行 query3。

另请参阅此处:http://www.faqs.org/docs/ppbook/x15040.htm

更新

完成交易:

List object = null; 
try {
org.hibernate.Transaction tx = session.beginTransaction();
try {
Query q = session.createQuery("from Table where lower(translatedText) like lower('%" + term + "%') or lower(translatedAscii) like lower('%" + term + "%') or lower(originalAscii) like lower('%" + term + "%')");
object = (List<Table>) q.list();
} catch (Exception e) {
e.printStackTrace();
} finally {
//You can safely rollback here because you are not changing anything in the DB.
//If you change something, you should commit transaction at the end of try block,
//and here check if it is still active and rollback if it is.
tx.rollback();
}
return object;
} catch (HibernateException e) {
throw new RuntimeException("Could not begin transaction");
}

关于Hibernate 错误 : current transaction is aborted, 命令被忽略,直到事务 block 结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3672219/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com