I have an application which works on Spring MVC and Hibernate . It works fine if a single user insert a record, but if multiple user insert records concurrently at same time . It shows this error "Hibernate: org.hibernate.AssertionFailure: null id in".I can observe this is happening because the automatic primary id genaration by hibernate for all record can be similar because of same time. not sure about this.Please help. Need a crucial fix.
The code I use as follow
@Transactional
public Account addAccount(Account acct) {
session = sessionFactory.getCurrentSession();
session.save(acct);
session.flush();
session.clear();
return acct;
}