This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am having trouble with updating an entity bean that's on the many side of a one-to-many relation. The entity bean owning the relation is Customer (on the one side); the other side is PhoneNumbers (many side): i.e., one customer can have many phone numbers.
Here are the two ways I tried, but neither worked correctly:
1. This ends up with a new row in the PhoneNumber table and it's orphaned also. The old row didn't get updated either.
2. This ends up with a new row in the PhoneNumber table with the proper relationship set up. But, the old row didn't get updated.
em is the EntityManager; customer is the Customer entity bean; phoneNumber is the updated PhoneNumber entity bean that belongs to customer;
In your mapping of the Association, The Collection of Phone Numbers in the Customer class, what Cascade options did you choose. That determines how a JPA implementation will save/update/delete associations. You will probably want "persist, delete" Cascade options.
Mark [ February 09, 2007: Message edited by: Mark Spritzler ]