Skip to main content

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

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


Back to the top