除了加载时之外,Hibernate 什么时候调用 setter?
我知道当你查找 bean 时 Hibernate 会调用 setter。
但我最近注意到当我们没有进行任何查找时,Hibernate 会调用 setter。我们已经创建了 POJO,然后调用了 save。在这种情况下,为什么 Hibernate 会调用 setter?
更新:当我们实际在 Hibernate 实体上调用 delete()
时,setter 调用似乎正在发生。为什么 Hibernate 在这种情况下调用 setter?
I know Hibernate calls setters when you lookup a bean.
But I recently noticed the setter was being called by Hibernate when we were not doing any lookups. We had created our POJO's and then called save. Why would Hibernate call setters in this case?
Update: The setter call seems to be happening when we are actually calling delete()
on a Hibernate entity. Why does Hibernate call the setter in this case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,不应该。
Hibernate 将为任何生成的字段(例如任何生成的 ID)调用 setter。也许他们将其扩展为覆盖所有字段,以防在保存期间或某些此类边缘情况下触发更新字段。
As far as I was aware, it should not.
Hibernate will call the setter for any generated fields, such as any generated IDs. Perhaps they extended this to cover all fields in case a field is updated by a trigger during the save or some such edge case.