Another problem I’ve it recently with saveOrUpdate that can be fix by using the same saveOrUpdate but give the class name.
Using the session.saveOrUpdate(myObject) might give you a unknown entity while using the same method with the class name in parameter won’t.
session.saveOrUpdate(myObject); //give a unknown entity session.saveOrUpdate("MyObjectClassName", MyObject); //Work
The important difference between the org.hibernate.Session class methods, save & saveOrUpdate is, save generates a new identifier and results in an INSERT query, whereas saveOrUpdate does an INSERT or an UPDATE.
For a more complete summary of what each of these method do check the hibernate site or this stackoverflow question/answer
Recent Comments