如何推迟 JBoss 5.1 中 CMP2.1 bean 的实际数据库插入?

发布于 2024-09-14 00:50:03 字数 602 浏览 2 评论 0原文

我正在将 Weblogic 9 应用程序迁移到 JBoss 5.1,并遇到以下问题:

会话 ejb 管理 CMP 2.1 实体。这些是在调用 MyEntityLocalHome.create() 方法时插入的。由于数据库表具有“非空”约束,因此某些通常在调用 create() 方法后设置的字段未设置,因此插入失败。

我知道如果经理调用了 create(myNotNullField);方法,传递正确的参数,问题就解决了。不幸的是,管理器使用一个层在运行时发现应该调用哪个 *LocalHome 和哪个 create() 方法(通过内省),并且创建方法是使用实​​体的 PK 字段发现的。这意味着该层无法找到其参数不属于 PK 一部分的 create() 方法。

在 JBoss 文档中,我找到了一个参数 (insert-after-ejb-post-create),它允许我推迟 ejbPostCreate(...) 方法之后的插入,但这也不能解决我的问题,因为“ LocalHome.create() 调用在数据库插入后仍然返回。

如何将数据库中的实际插入延迟到事务结束,以便管理器可以设置“not null”字段? ,我猜WLS中存在这样的选项...Jboss 5.1中是否存在此参数?

感谢您的帮助:)

I am migrating a Weblogic 9 application to JBoss 5.1, and bumped into the following problem:

A session ejb manages CMP 2.1 entities. Those are inserted at the time of the call to MyEntityLocalHome.create() method. Since the database table has "not null" constraints, some of the fields, who are normally set after the call to the create() method, are not set and the insertion fails.

I know that if the manager called a create(myNotNullField); method, passing the correct parameters, the problem would be solved. Unfortunately, the manager uses a layer that discovers at runtime which *LocalHome and which create() method should be called (by introspection) and the create method is discovered using the PK fields of the entity. That means that the layer cannot find create() methods with parameters that are not a part of the PK.

In the JBoss docs, I found a parameter (insert-after-ejb-post-create) that allows me to postpone the insertion after the ejbPostCreate(...) method, but that doesn't solve my problem either, since the "LocalHome.create() call still returns after the DB insertion.

How can I delay the actual insertion in the DB to the end of the transaction, so that the manager can set the "not null" fields? Since the app works in Weblogic 9, I guess that such an option exists in WLS... does this parameter exists in Jboss 5.1?

Thanks for your help :)

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

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

发布评论

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

评论(1

甜警司 2024-09-21 00:50:03

这是通过使用 standardjboss.xml 中的 cmp2.x jdbc2 配置并将 insert-after-ejb-postprocess 设置为 false 来完成的。

This was done by using the cmp2.x jdbc2 configuration, in standardjboss.xml, with insert-after-ejb-postprocess set to false.

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