How to trigger Entity's callback method? [message #629014] |
Sun, 26 September 2010 01:26 |
No real name Messages: 1 Registered: September 2010 |
Junior Member |
|
|
In my project(JPA2.0,EclipseLink,mysql),I have a entity listener. For example,When entity updated, the method with annotation '@postupdate' will be triggered. This works well.
But sometimes,user updated the entity(getEntityManager().merge), JPA provider will check whether entity's property changed. If there is no change in entity, JPA provider will not update this entity because no SQL needs to be sent to the database.(This is cache mechanism,I think). So the the method marked '@postupdate' will not be triggered. But I need the '@postupdate' method triggered.In fact,some other properties mark as '@Transient' changed.I need to solve these changes. So how to trigger '@postupdate' method at this situation?
|
|
|
Re: How to trigger Entity's callback method? [message #629247 is a reply to message #629014] |
Mon, 27 September 2010 15:27 |
|
@PostUpdate is only trigger if the object will be updated. merge does not mean update.
EclipseLink offers several other events than the JPA events, these are defined through the DescriptorEventListener interface (or DescriptorEventAdapter). You could use the postMerge event to merge your transient fields, or use the pre/postWrite event which I think is always called.
James : Wiki : Book : Blog : Twitter
|
|
|
Powered by
FUDForum. Page generated in 0.03202 seconds