You might want to have a look at using versioning:
| @Version
| public int getVersion()
| {
| return version;
| }
| public void setVersion(int version)
| {
| this.version=version;
| }
|
Depending on what you need to do you could use the version to see if there have
I don't think it is possible to use @AroundInvoke within an entity. I started
to write an AOP interceptor which can intercept all set methods for a class
annotated with @Entity. This would allow me to do something similar to your
example. However I think that this would have a bigger overhead
How about:
@AroundInvoke
|public Object myBeanInterceptor(InvocationContext ctx) throws Exception
|{
| if (ctx.getMethod().getName().startsWith(set))
| {
| // FIXME: set that field to dirty
| // Don't forget to compare
| }
|
|
Note that the PreUpdate callback can be called anytime within your transaction
(EJB3 PFD 3.4.2).
Try the following:
@PostLoad
| protected void clearBits() {
|userIdChanged = false;
| }
|
| @PostPersist
| protected void possiblyNotifyUser() {
|if(userIdChanged)
This code does work, but I am looking for something more generic as I will need
to perform various different tasks for different fields on different entities.
To determine whether any field has changed on any entity, I would potentially
have to add code to all my set methods to flag the field