Hi, I have a method that updates the object X (Train with passengers) that is a parent to its children (passengers). When I update object X (Train) I execute session.saveOrUpdate(plane) for object X (this successfully updates object X), then I want to delete all of its old children and re-insert the new ones (as the children could have changed in meantime). Most of the new children will have the same id (primary key) as the old ones. When I do it in one session, Hibernate complaints that two different objects with the same id are associated with the same session – fair enough – the deleted one is probably still in the cache, so the new one is treated as the different object with the same id. My question is, how to tell hibernate to forget about that ones I have deleted (wipe them out of the cache) and re-insert the new ones (in the same session) – which would also work for new children, that did not exist previously. Any ideas how to do it? Very appreciated, Janusz
|