openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Heiko Kopp <>
Subject Re: EntityNotFoundException caused by EntityManager.refresh()
Date Wed, 14 Apr 2010 17:31:42 GMT

Hello Mike,

that is true, one entity in the OneToMany relationship (one of the
addresses) has been deleted in the database. 

Thus the situation would be as follows:

first find of a person leads to:

   - List of Addresses
          Address A
          Address B

Now Address B is deleted from the database by an external, non-controllable

If I now do a find on Person and a subsequent call to refresh() on the
person object, the Person still exists, and the entity of Address B in the
list of addresses exists too (being in an undefined state, halfway
detached?), but no longer in the database. I think thats what leads to the
EntityNotFoundException. Interestingly, this is not always the case, just
sometimes the situation occurs. 

I will asap try the newest snapshot of 1.3 and try this one. Maybe things
have fixed already.

Thank you for your help. Unfortunately I'm not able to switch to OpenJPA 2.0
cause WebSphere 6.1 does not work with it :-(

What is in general the correct way of handling an EntityNotFoundException?
Should the base entity (Person) be detached? 

I was thinking of trying to use a NamedQuery that does a SELECT p from
Person p WHERE = ... instead of doing a find(), though unsure if that
is in any way different to a find.

Any further ideas are appreciated. I will be back with news of the newest
snapshot of 1.3.

Best regards,

View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message