I am wondering about the use of
Code:
saveOrUpdateCopy()
operation in
Code:
HibernateTemplate
.
When it is recommended to use
Code:
saveOrUpdateCopy()
versus the regular operation
Code:
saveOrUpdate()
. In my application, for update of an object I need to make a comparison between the new object passed with the existing object in the database and I do the update for the new object, but I am getting the NonUniqueObjectException, but this is resolved once I used the
Code:
saveOrUpdateCopy()
method.
Is it being recommended to use
Code:
saveOrUpdateCopy()
under this situation? Or is there any other better alterantive?
Environment: Spring version = 1.1.1, hibernate (v 2.x)
UpdateBusinessObj(A a1)
{
A a2 = template.get(a, a.getIdentifer());
// do some business validation between a1 and a2
template.update(a1); // this lines throws NonUniqueObjectException exception
}
Your help is highly appreciated.
Arshad
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: