0

This is the piece of code from my program,in which I have tried to insert into Question table with hibernate saveOrUpdae() method.

this.txTemplate.setReadOnly(false);
this.txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
        this.txTemplate.execute(new TransactionCallbackWithoutResult() {
        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status)
        {
             questionManager.saveQuestionsofCurrentUser(filteredStreamDataMapForCurrentUSer.values(),user);
                 questionManager.updateQuestionsReady1on2(user);  

        }
});

When try to run with multiple users, I am getting org.hibernate.NonUniqueObjectException:.The process run using multi thread concept.Any one can suggest a solution for it?

Coder
  • 6,948
  • 13
  • 56
  • 86
Vishnupriya
  • 111
  • 3
  • 10
  • have you tried auto-increment option? – Abubakkar Jul 24 '13 at 10:44
  • primary key is not auto incremented one it is aaigned from our code. – Vishnupriya Jul 24 '13 at 10:49
  • 1
    possible duplicate of [Hibernate Error: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session](http://stackoverflow.com/questions/1074081/hibernate-error-org-hibernate-nonuniqueobjectexception-a-different-object-with) – Emilio Jul 24 '13 at 10:51
  • Have you printed out the primary keys of the objects before calling saveOrUpdate? Are you sure you don't have two objects with the same primary key? – Pace Jul 24 '13 at 13:14

0 Answers0