Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Merged entity question

Hi,

I'm using eclipselink with JPA 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 one question:

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.

For example, imagine that newEntity is a new entity not managed but
with an id attribute existing in DB. If I type:

Operator entity = em.merge(newEntity);

entity has the values of newEntity. I'd like a mix between both
entities: the previous persisted and the new values from the new
entity.

Thanks.


Back to the top