Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Related entity in a one-to-many relationship not being updated

Using Eclipselink 2.0.0

The setup goes something like this:

public class Registration {
  ..
  @OneToMany(mappedBy = "registration", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
  private Collection<Approval> approvals;
}

Imagine now a registration with 1 approval.  Then the user adds a new one.  The business logic calls for the previous one to be deactivated and the new one be set active.

public void bizLogic(...) {
  // load registration from DB
  // append a new approval to approvals collection
  // deactivate the old approval in the collection.
  // save registration to the database.
}

Stepping through the code with the debugger, I can see that the necessary business logic steps are undertaken.  Then when I commit changes to the database (by saving the Registration), the following take place:

*       Changes to the Registration are persisted
*       A new approval is persisted

Conspicuous by its absence is an update of the first approval.

What step am I missing?  FWIW, setting the approvals collection to FetchType.EAGER make no difference.

Sri



Back to the top