openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "C N Davies" <>
Subject RE: PreUpdate listener is very nosey!
Date Wed, 19 May 2010 18:06:37 GMT
Only the single entity will have been modified,  I was expecting as you say
that only modified entities would be running PreUpdate. I'm using OpenJPA
2.0.0 GA.


 Looked at 1.3.2.  PreUpdate/PostUpdate Life Cycle Callbacks   but since
these entities have not be touched in anyway other then to retrieve them, I
don't' thin it is relevant.








From: Kevin Sutter [] 
Sent: Thursday, 20 May 2010 1:55 AM
Subject: Re: PreUpdate listener is very nosey!


If the Entities in your persistence context (EM) have not been modified, but
preUpdate is being called for them, then this sounds like a bug.  The
preUpdate should only be called for Entities that have actually been
updated.  And, it makes sense that if you close/clear the EM before doing
the merge(), then the only Entity in your EM is the one being modified.

What version of OpenJPA are you using?  We did make a change in this area
due to the JPA 2.0 spec so that certain callback methods would not be called
between the persist and commit methods [1].  But, your situation sounds
different from that.


On Wed, May 19, 2010 at 10:40 AM, C N Davies <> wrote:

My code loads a collection of entities using findall(class). The em is left
open rather than having to open and close it every time the user performs an
operation on one of these objects in the list.

Below is my PreUpdate listener for that entity, so I know when it is getting
called I have system.out right now.

The problem is that if I use em.merge(entity)   the PreUpdate listener will
be called on each one of the entities in the list not only the entity I am
merging. If I close the em and create a new one then call em.merge(entity),
the PreUpdate listener will only be called on the entity I am merging.


     public void update(){

           System.out.println("Running preupdate dataload listener");



I expected this would be due to runtime enhanced classes so didn't pay much
attention to it, but now I  have being using it after build time enhancing
my classes I have the same issue. It seems like it wants to run the
PreUpdate listener on anything of this entity class that is attached to the
current em.

Have anyone seen this before?



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message