Gethibernatetemplate saveorupdate not updating
LAST_NAME as LAST_NAM3_1_0_ from Employee employeeen0_ where employeeen0_. temp In discussion of save() method, we forgot about case where we had to save persistent entity in another session and that got resulted in duplicate key error.
If you understand the hibernate mechanism clearly, it doesn’t execute the SQL statements directly to manipulate the database, hibernate itself a state maintaining mechanism. Here you can specify which entity you are saving using save() method. ) Hibernate: insert into Employee (FIRST_NAME, LAST_NAME, ID) values (? Let’s write down a simple example to see above theory in practical: Employee public class Save Entity Again In Another Session Hibernate: insert into Employee (FIRST_NAME, LAST_NAME, ID) values (? We have learned that hibernate works only with persistent entities and persistent entities are classes which are attached to any hibernate session. Please not that creating an instance of a class, you mapped with a hibernate annotations, does not automatically persist the object to the database.