Reputation: 21
when inserting into the database using persist function in hibernate session
it sometimes duplicates rows , is it a problem with hibernate ?
currentSession.persist(cloudUser);
currentSession.flush();
tx.commit();
Upvotes: 0
Views: 262
Reputation: 5710
You have two methods to persist your object. save () and persist()... While taking decision ,ID generation strategy also should be taken into the consideration. Save method will fire insert query immediately but persist() will not..
Clcik Here
Upvotes: 0
Reputation: 165
persist() method doesn't guarantee that the identifier value will be assigned to the persistent instance immediately, the assignment might happen at flush time.
Upvotes: 1