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] Sun, 26 September 2010 01:26 Go to next message
No real name is currently offline No real nameFriend
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 Go to previous message
James Sutherland is currently offline James SutherlandFriend
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:Query.setMaxResults(0) seems to fail
Next Topic:Cannot access a secure jms coordinated cache topic on JBoss AS
Goto Forum:
  


Current Time: Fri Jul 28 01:01:31 GMT 2017

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

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