为什么 hibernate 的 ClassMetadata.getIdentifier(Object, EntityMode) 被弃用
刚刚升级到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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也问自己同样的问题。我不知道为什么要这样做,但现在我们需要一些脏的铸造来使用公共 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.