Question

I have implemented a DescriptorEventAdapter for JPA (eclipselink). It performs simple timestamp operations. The preUpdate method is being called, however it is being called too often. It gets called and updates the timestamp, even on find/select operations.

The issue I'm running into appears to occur in a different JPA framework also, http://markmail.org/message/nank44rgp4xi2ita#query:JPA%20preupdate%20being%20called%20after%20find+page:1+mid:xssqpg7hm4mesfl5+state:results.

I have attempted to:

  • check the ChangeSet on the DescriptorEvent, this is always null
  • check the code on the DescriptorEvent, this is always 6

I have not been able to find any other flag or attribute that says "this object really was updated".

How do I get preUpdate to act only when a record really was updated and not merely selected?

Was it helpful?

Solution

http://wiki.eclipse.org/Configuring_a_Descriptor_(ELUG)#Table_115-27

The preUpdate is called all the time, apparently. aboutToUpdate is the better method to call to trigger when an update needs to be done.

OTHER TIPS

Here's the solution i came up with after reading this question; I also found that the ChangeSet on the DescriptorEvent always seems to be null.

I did however notice that the event has methods to get the before and after objects:

 Object oldObject = event.getOriginalObject();
 Object newObject = event.getSource();

which would allows you to do manual comparison of the fields. Using reflection you can write a bit of code that could compare all the fields in any class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top