-
1. Re: Unnecessary read before update with merge()
epbernard Dec 6, 2006 8:32 PM (in response to markvl)This is as per the spec. The behavior you want is available when you do session.saveOrUpdate()
Both have merit. -
2. Re: Unnecessary read before update with merge()
epbernard Dec 6, 2006 8:36 PM (in response to markvl)To expand it a bit. If you expect mostly updates from your graph, saveOrUpdate is good, if you expect mostly unchanges objects in your graph, merge is good.
Hibernate optimize things under the hood (merge profile / batch update), the different does not matters in most cases -
3. Re: Unnecessary read before update with merge()
markvl Dec 6, 2006 9:04 PM (in response to markvl)OK, so I can use an Hibernate extension to workaround the issue.
I see that the Hibernate doc says that merge() behaves this way (http://www.hibernate.org/hib_docs/entitymanager/reference/en/html_single/#d0e897), but where can I found the EJB3 spec stating this should be the behaviour of merge()? I can't find that being covered in the Sun doc.
It would be nice if the EJB3 spec provided a way of avoiding this inefficiency.