JPA and merging

View: New views
1 Messages — Rating Filter:   Alert me  

JPA and merging

by bea-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm using JPA (version 1.0.2) in order to manage some entities.
Right now I've one entity called Operator with an attribute called Contacts, that is a relation-ship one-to-many to other table, with a cascade type ALL.

Some times I update the Operator and the nested Contacts with the merge method. I've two questions:

1. Is there any way to delete or add a nested contact in the update operation? ie, I update some date of the operator with a merge and at the same time I wanto to delete one of its contacts.

2. If I've an entity of the database persisted, and I've a new entity with the same ID than the one persisted but some data modified, could I merge the second entity with the first one with a simple merge method? If I do that all the old data not represented in the new entity is removed.



Thanks