尝试将数据输入数据库时​​出现 InvalidStateException

发布于 2024-10-09 10:28:07 字数 922 浏览 4 评论 0原文

我有一个方法可以返回特定数据库的实体管理器。现在,当我第一次使用该方法来获取实体管理器时,一切正常。我可以使用实体管理器将数据保存到任何表 A、B、C 中。现在说我在表 B 中保存时出现异常

现在,当我在获得上述异常后尝试对数据库执行任何操作时,下次我尝试运行相同的代码时,在表 A 本身中更新时会失败。我可以看到以下接收结果

                                 <openjpa-1.2.2-SNAPSHOT-r422266:778978M-OPENJPA-975 nonfatal user error> org.apache.openjpa.persistence.InvalidStateException: The factory has been closed.  The stack trace at which the factory was closed is available if Runtime=TRACE logging is enabled.
    at org.apache.openjpa.kernel.AbstractBrokerFactory.assertOpen(AbstractBrokerFactory.java:673)
    at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:182)
    at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
    at ..

I have a method that return the entity manager for particular DB.Now when i use the method for the first time to get entity manager everything works fine.I can save data into any tables A,B,C using entity manager.Now say i get a exception while saving in table B

Now when I try to perform any operation on DB after geting exception above, the next time i try to run same code it fails when updating in table A itself.I can see folloing eception

                                 <openjpa-1.2.2-SNAPSHOT-r422266:778978M-OPENJPA-975 nonfatal user error> org.apache.openjpa.persistence.InvalidStateException: The factory has been closed.  The stack trace at which the factory was closed is available if Runtime=TRACE logging is enabled.
    at org.apache.openjpa.kernel.AbstractBrokerFactory.assertOpen(AbstractBrokerFactory.java:673)
    at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:182)
    at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
    at ..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

逆蝶 2024-10-16 10:28:07

在代码中的某个位置,您(或框架)关闭您的 EntityManagerFactory。确保您没有对其调用close()

Somewhere in your code you (or a framework) close your EntityManagerFactory. Make sure you didn't call close() on it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文