| Author |
Session.evict() and update() doesn't works.
|
Kunal Lakhani
Ranch Hand
Joined: Jun 05, 2010
Posts: 609
|
|
I am updating a record with the following code :
The table which gets updated has composite primary key (class,section,rollno,year)
But this code throws an exception relating to primary key violation.
I wonder how pk is violated, since the rollno is changed, and this rollno is not allotted to anyone.
Strange thing is that this code works with same values
In this code i have deleted the old record and then, save the new one (wrong way of updating)
|
kunal
|
 |
James Boswell
Ranch Hand
Joined: Nov 09, 2011
Posts: 657
|
|
|
Have you tried the call to update() method without the call to evict?
|
 |
Kunal Lakhani
Ranch Hand
Joined: Jun 05, 2010
Posts: 609
|
|
Thanks for your reply James Boswell.
No , i haven't tried that.
But before trying that i wonder why the code posted by me doesn't works
|
 |
Kunal Lakhani
Ranch Hand
Joined: Jun 05, 2010
Posts: 609
|
|
|
The problem i am facing is that the delete() deletes all the records with that specified roll no regardless of year.
|
 |
James Boswell
Ranch Hand
Joined: Nov 09, 2011
Posts: 657
|
|
|
How have you defined your composite key on the entity? It sounds like it isn't working correctly.
|
 |
 |
|
|
subject: Session.evict() and update() doesn't works.
|
|
|