Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » How to trigger Entity's callback method?
How to trigger Entity's callback method? [message #629014] Sat, 25 September 2010 21:26 Go to next message
Eclipse UserFriend
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 11:27 Go to previous message
Eclipse UserFriend
@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.
Previous Topic:Cache replication problem with UpdateAllQuery
Next Topic:EclipseLink 2.1.0 and Exception [EclipseLink-6004]
Goto Forum:
  


Current Time: Wed Jul 16 06:07:21 EDT 2025

Powered by FUDForum. Page generated in 0.31764 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top