I'm having problems with a NonUniqueObjectException
thrown by Hibernate.
Reading the docs, and this blog post, I replaced the call from update()
to merge()
, and it solved the problem.
I believe I understand the reason for the exception, and why changing the method fixed the problem, in terms of disconnected objects and session boundaries.
My question is : given that merge()
will always resolve to the session object, or retrieve it if it doesn't exist, is calling merge() generally a safer alternative than update()
?
What is the downside of using merge()
over update()
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…