使用 hibernate 中的 toplink

发布于 2024-08-09 07:51:50 字数 163 浏览 6 评论 0原文

我正在使用 hibernate,但我想添加一个使用 hibernate 的应用程序。我面临的问题是当我想在该组合应用程序上执行全局事务时。我使用 weblogic 作为容器,现在的问题是 hibernate 创建了自己的连接,我希望 toplink 应该只使用该连接...任何人都可以告诉我如何实现这一点吗???

i am using hibernate but i want to add an application that is using hibernate. the problem that i am facing is when i want to perform global transaction on that combined application. i am using weblogic as container, now the problem is that hibernate created its own connection, i want that toplink should use that connection only... can any one tell me how can i achieve that?????

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

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

发布评论

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

评论(2

七度光 2024-08-16 07:51:50

我建议将 Hibernate 和 TopLink 世界分开,并为 Hibernate 方面使用一个 EJB Session bean,为 TopLink 方面使用另一个 EJB Session bean。

使用容器管理的事务并让 WebLogic 服务器负责跨两个会话 bean 调用的提交。您可能需要一个用于 TopLink 工作的数据源 + 连接池,以及用于 Hibernate 工作的不同数据源 + 连接池。

这样,您就可以在两种 ORM 技术之间实现适当的架构分离。我怀疑尝试使用 TopLink 工作中的相同连接并将其传递给 Hibernate(反之亦然)将不起作用,因为一旦一个工具调用了提交,那么另一个工具就无法调用回滚

:-)在 EJB 层,这比直接使用 JTA 更容易。容器应该为您处理 JTA 的事情。

I'd suggest keeping the Hibernate and TopLink worlds separate and use one EJB Session bean for the Hibernate side of things and another EJB Session bean for the TopLink side of things.

Use container managed transactions and let the WebLogic server take care of the commit across both session bean calls. You may need one data source + connection pool for the TopLink work and a different data source + connection pool for the Hibernate work as well.

This way you have proper architectural separation between the two ORM technologies. I suspect that trying to use the same connection from the TopLink work and passing it to Hibernate (or vice versa) won't work because once one tool has called commit then the other tool can't call rollback :-)

Is you do things at the EJB layer it will be easier than mucking about with JTA directly. The container should take care of the JTA stuff for you.

我纯我任性 2024-08-16 07:51:50

您是否担心多个连接或合并事务?如果您希望您的 toplink 代码和 hibernate 代码共享事务,您可能需要查看 JTA 将它们组合成分布式事务。否则,我不清楚你想要实现什么目标

Are you concerned about multiple connections or combining transactions? If you want your toplink code and your hibernate code to share transactions you're probably going to have to look at JTA to combine them into a distributed transaction. Otherwise, I'm unclear on what it is you're trying to accomplish

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