This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Object Relational Mapping and the fly likes JDO issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JDO issue" Watch "JDO issue" New topic

JDO issue

Arun Raja S.K

Joined: May 30, 2011
Posts: 8
I am working on a project and would be grateful if i get a solution. The issue is , i try to perform a delete a row first and next insert a row operation in a table (update is complex here so performing delete and insert ). The table has two constraints, one is primary key constraint and other is unique key constraint (which is a combination of 4 columns). here primary key is a number sequence which automatically increases by 1 whenever a insert happens.

Unique constraint exception is thrown when i try to delete a row and insert a row which has different value in primaryid column and has same values in all other 4 columns as deleted row.

why this exception occurs even though i try to delete the row first and then try to insert new row in table ?

From java side, I first use deletePersistentAll() method to delete the rows and setColumnName() methods to insert values for each columns and then i call makepersistent() method to persist the objects. All this JDO method calls happens as part of Transaction
and Unique constraint exception is thrown when executing commit and transaction is rolled back.

what change i should do to avoid this exception from occuring ?.
I agree. Here's the link:
subject: JDO issue