使用 Spring 3.1 和 Hibernate 4 时替换 IdTransferringMergeEventListener

发布于 2025-01-05 11:14:26 字数 941 浏览 0 评论 0原文

org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener 是否有 Hibernate 4 版本?

我正在尝试将 Spring 3.0.x + Hibernate 3.6 应用程序升级到 Spring 3.1 + Hibernate 4,但似乎找不到如何更新它。

这在我的 applicationContext 中特别引用,如下所示:

<property name="eventListeners">
      <map>
        <entry key="merge">
          <bean
            class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener" />
        </entry>
      </map>
</property>

保持原样会导致异常:

Caused by: java.lang.ClassNotFoundException: org.hibernate.event.def.DefaultMergeEventListener
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)

大概是因为 Hibernate 4 不再具有类 DefaultMergeEventListener

提前致谢。

Is there a Hibernate 4 version of org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener?

I'm attempting to upgrade my Spring 3.0.x + Hibernate 3.6 app to Spring 3.1 + Hibernate 4 but can't seem to find how to update this.

This specifically is referenced in my applicationContext as so:

<property name="eventListeners">
      <map>
        <entry key="merge">
          <bean
            class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener" />
        </entry>
      </map>
</property>

Just leaving it as is causes an exception:

Caused by: java.lang.ClassNotFoundException: org.hibernate.event.def.DefaultMergeEventListener
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)

presumably because Hibernate 4 does not have the class DefaultMergeEventListener anymore

Thanks in advance.

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

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

发布评论

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

评论(2

梨涡少年 2025-01-12 11:14:26

看起来该类已移至 org.hibernate.event.internal.DefaultMergeEventListener

it looks like the class moved to org.hibernate.event.internal.DefaultMergeEventListener

傾旎 2025-01-12 11:14:26

Spring 人员决定不在 Hibernate 4 中实现此功能

来自 Spring 错误报告: https://jira .springsource.org/browse/SPR-9634

我们有意将 Spring 对 Hibernate 4 的支持保持在最低限度,以便接近原生 Hibernate 4 的工作方式。因此,我们没有计划重新引入 IdTransferringMergeEventListener 或任何以前的 LOB 用户类型,所有这些都是特殊用途的类,用于解决 Hibernate 真正应该自行解决的问题 - 因为它们与 Spring 无关并导致重复Spring 方面的维护难题。

当然,您可以根据 Spring 的旧 IdTransferringMergeEventListener 自由创建自己的版本。但是,请注意,事件侦听器的注册方式在 Hibernate 4 中已发生变化:这在每个 SessionFactory 级别上不再可能,因此 Spring 也无法在其 LocalSessionFactoryBean 中提供支持。有关详细信息,请查看相应的 Hibernate 文档和 Hibernate JIRA 上的相应报告。

于尔根

The Spring folks decided not to implement this for Hibernate 4

From bug report in spring: https://jira.springsource.org/browse/SPR-9634

We intentionally kept Spring's Hibernate 4 support rather minimal, in order to stay close to the native Hibernate 4 ways of doing things. As a consequence, we have no plans to reintroduce IdTransferringMergeEventListener or any of our former LOB user types, all of which were special-purpose classes to work around issues that Hibernate should really solve itself - since they have nothing to do with Spring and caused repeated maintenance headaches on Spring's side.

You're free to create your own version based on Spring's old IdTransferringMergeEventListener, of course. However, note that the way that event listeners can be registered has changed in Hibernate 4: This is not possible on a per-SessionFactory level anymore, hence Spring cannot support in its LocalSessionFactoryBean either. Check the corresponding Hibernate documentation and the corresponding reports on the Hibernate JIRA for details.

Juergen

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