我已经为 JPA 实现了 DescriptorEventAdapter (eclipselink)。它执行简单的时间戳操作。正在调用 preUpdate 方法,但调用频率过高。即使在查找/选择操作中,它也会被调用并更新时间戳。
我遇到的问题似乎也发生在不同的 JPA 框架中,http://markmail.org/message/nank44rgp4xi2ita#query:JPA%20preupdate%20being%20called%20after%20find+page:1+mid:xssqpg7hm4mesfl5+state:results 。
我尝试过:
- 检查更改集 DescriptorEvent,始终为 null
- 检查代码 DescriptorEvent,这始终是 6
我无法找到任何其他标志或属性表明“此对象确实已更新”。
如何让 preUpdate 仅在记录真正更新而不仅仅是选择时才起作用?
最佳答案
http://wiki.eclipse.org/Configuring_a_Descriptor_(ELUG)#Table_115-27
显然,preUpdate 一直被调用。 aboutToUpdate 是需要完成更新时调用触发的更好方法。
关于java - JPA PreUpdate 使用在 find/select 之后调用的 DescriptorEventAdapter 实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2232424/