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();
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();
persist() method doesn't guarantee that the identifier value will be assigned to the persistent instance immediately, the assignment might happen at flush time.
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