Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Insertions missing

I do not understand what you are referring to by “first transaction”.  Here’s a little more detail on the implementation:

 

Precondition: Company has 3 Employees E1, E2, E3

User issues “delete E3” and “add E4” request

 

The server logic is implemented thusly:

 

1)       Find Employee E3 in Company’s collection of Employees

2)       Remove E3 from the collection – A pure Java operation, i.e. no dao.delete(employee)

3)       dao.flush() – to ensure that the delete operation is executed.  This is to work around Eclipselink’s desire to perform inserts first (It is a longer sidebar to explain why we don’t want that to happen)

4)       Add E4 to the Company’s collection of Employees

5)       Save the Company to the database

 

Steps 1-5 are all a part of the same transaction.

 

The same steps repeat when user subsequently asks to delete E4 and add E5.  It fails at step 2 saying that E4 does not exist.

 

Sri

 

From: eclipselink-users-bounces@xxxxxxxxxxx [mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of Christopher Delahunt
Sent: Friday, July 29, 2011 1:55 PM
To: EclipseLink User Discussions
Subject: Re: [eclipselink-users] Insertions missing

 

Does the second step wait for the first transaction to commit before reading in the company?  If not, you many need to refresh the company after the transaction is fully committed to see the changes as they are not visible to other contexts until the commit occurs.

If this isn't the issue, can you describe the api you are using in each step?

Best Regards,
Chris

On 29/07/2011 12:41 PM, Sri Sankaran wrote:

Eclipselink version: 2.0.0

 

Consider the following simplification of my actual business case:

 

A Company entity has a collection of Employee entities

 

@Entity

@Cache(shared = true, expiry = 900000)

@Table(name = "COMPANIES ")

public class Company {

  @OneToMany(mappedBy = "company", fetch = FetchType.EAGER, cascade = CascadeType.ALL)

  @PrivateOwned

  public List<Employee> getEmployees() {

    return this.employees;

  }

 

@Entity

@Cache(shared = true, expiry = 900000)

@Table(name = "EMPLOYEES ")

public class UsFinance {

  @ManyToOne(fetch = FetchType.EAGER)

  @JoinColumn(name = "COMPANY_ID", nullable = false)

  private Company company;

  …

}

 

Consider the case where a Company has 3 Employees (E1, E2 & E3). 

 

The user of the application (using the user interface) deletes E3 & adds E4.  The logic works correctly and E3 is removed from the database and an E4 is inserted.

 

Next, the user deletes E4 and adds E5.  Now when application attempts to perform this operation, I am told that the employees collection that is owned by the Company object does not contain an E4!!

 

How come?  Recall that in the previous step the insert happened correctly.  Equally puzzling – not to mention aggravating – is that if slowly step through the logic in a debugger I do not see any error.

 

I should also mention an ominous warning I see when I build the application: could not be weaved for change tracking as it is not supported by its mappings.

 

I have not figured its cause and I don’t know if this has any bearing on my current problem.

 

Sri

 

 

 
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
  

Back to the top