为什么 hibernate 的 ClassMetadata.getIdentifier(Object, EntityMode) 被弃用

发布于 2024-10-04 04:14:31 字数 645 浏览 0 评论 0原文

刚刚升级到hibernate 3.6.0,发现这个方法已经被弃用了。

public Serializable getIdentifier(Object object, EntityMode entityMode) throws HibernateException;

它已被此“取代”,

public Serializable getIdentifier(Object entity, SessionImplementor session);

我不确定为什么这样做,更重要的是,我不相信新方法是合适的替代品。

我有一些代码可以通过使用此 API 从 XML 创建 Hibernate 对象(属性 -> 属性等)以及其他一些片段来绑定 Hibernate 对象/属性。

我一直认为 ClassMetadata 是用于此目的的公共 API。我已经知道 SessionImplementor 是一个内部 API,不能作为应用程序代码使用。

假设我在上述两个断言中是正确的,公共 API 需要私有 API 作为参数似乎是错误的?

有谁知道为什么这样做以及我将来应该如何进行编程式休眠对象访问?

(有趣的是,获取/设置属性值方法仍然采用 EntityMode。)

Just upgraded to hibernate 3.6.0 and found that this method is deprecated.

public Serializable getIdentifier(Object object, EntityMode entityMode) throws HibernateException;

It has been 'replaced' by this

public Serializable getIdentifier(Object entity, SessionImplementor session);

I'm not sure why this has been done, and more importantly, I don't believe the new method is a suitable replacement.

I have code which binds hibernate objects/properties by using this API to create hibernate objects from XML (attributes->properties etc) and some other bits and pieces too.

I have always considered ClassMetadata to be a public API that is to be used for this purpose. And I have been aware that SessionImplementor is an internal API that is not for use be application code.

Assuming I am correct in the above two assertions it seems wrong that a public API requires a private API as a parameter?

Does anyone know why this was done and how I should be approaching doing programmatic hibernate object access in the future?

(Interestingly the getting/setting property value methods still take an EntityMode.)

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

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

发布评论

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

评论(1

中二柚 2024-10-11 04:14:31

我也问自己同样的问题。我不知道为什么要这样做,但现在我们需要一些脏的铸造来使用公共 API。这完全没有意义。

I ask myself the same question. I have no idea why this was done, but now we need some dirty castings to use a public API. That makes no sense at all.

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