Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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
No real name is currently offline 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 11:27 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

@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
Previous Topic:Cache replication problem with UpdateAllQuery
Next Topic:EclipseLink 2.1.0 and Exception [EclipseLink-6004]
Goto Forum:
  


Current Time: Sat Aug 30 10:34:52 EDT 2014

Powered by FUDForum. Page generated in 0.04961 seconds