Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Problem after trying to insert a new object

If an error occurs, you cannot continue to use the same EntityManager.  You
should either get a new EntityManager, or call clear().  All objects managed
by the EntityManager will become detached, you should not continue to use
these objects.

JPA does not provide for error handling.  EclipseLink's native UnitOfWork
API does have some support for error handling using its
commitAndResumeOnFailure, revert, API's, but these are not currently exposed
through JPA.

Rodrigue Lagoue Njinthe wrote:
> Hi all!
> i have a curious problem using eclipselink
> i have the following classes
> public class HealthProfessional {
>     private Institution institution;
> }
> public class Network {
>     private List<Institution> institutions;
> }
> public class Institution {
>   private List< HealthProfessional  > healthprofessionals;
> }
> NB: i remove the jpa annotations, but i can assure that they are correct.
> The problem:
> I use stored procedures (i configured it by implementing the
> DescriptorCustomizer interface) to write changes and new object to an
> oracle
> Database (10g), and read information from views.
> But by adding a new HealthProfessional there is an exception thrown from
> the
> database (the issue is being resolved by somebody else). Since i use a
> strongly tied domain model, i build all the  relations between the
> instances
> involved before saving. I catch the exception coming from the database and
> suppose the system would continue to work without problem.
>  - But the next time i tryied to refresh the corresponding network, i get
> an
> Exception from the EntityManager telling that the Network instance is no
> more managed.
>     - so i fixed by catching the exception and retrieve a new instance
> using
> EntityManager#find() method
> - by the next commit (another use cases) i find out that the old network
> instance is always somewher in the session, because eclipselink tries to
> insert it (as new object), although  the id is already setted on it.
> A possible solution could be to set eclipselink so that, it insert objects
> only if it was explicitely required (calling EntityManager#persist() or
> EntityManager#merge() methods). Is there a way to do it?
> if not, how can i solve the problem
> thanks for any help
> Rodrigu

--- James Sutherland
 EclipseLink ,
Wiki: EclipseLink , TopLink 
Forums: TopLink , EclipseLink 
Book: Java Persistence 
View this message in context:
Sent from the EclipseLink - Users mailing list archive at

Back to the top