MountainClimb / datanucleus-appengine

Automatically exported from code.google.com/p/datanucleus-appengine
0 stars 0 forks source link

Primary key Exception not came when it the Duplicate value manually inserted. #175

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.String Primary Key.
2.Insert the Value manually.
3.When the Primary key inserted with same value which was already there it 
does not give Duplicate Primary Key exception

What is the expected output? What do you see instead?
Instead of showing Duplicate Primary Key Violation it Update the Existing 
Value.

What version of the product are you using? On what operating system?
GAE 1.2.6
GWT 1.7.1
Windows Vista
Eclipse 3.5
Java 1.6 

Please provide any additional information below.

Original issue reported on code.google.com by vinayaga...@gmail.com on 17 Dec 2009 at 9:43

GoogleCodeExporter commented 8 years ago
Yes. I am also facing the same problem.

Original comment by surendr...@gmail.com on 18 Jan 2010 at 7:28

GoogleCodeExporter commented 8 years ago
The datastore does not distinguish between insert and update so this behavior, 
while 
unexpected, makes sense to me.  If you want to know if a record exists with a 
given 
primary key, start a txn and attempt to fetch the record by the pk.  If the 
record exists 
then you've got your answer.  If the record does not exist you can then insert, 
and since 
you're using a txn, if someone else inserts a record with that pk in between 
the time 
you fetched and inserted, you'll get a ConcurrentModificationException, which 
is 
another indication that the record already exists.

Original comment by max.r...@gmail.com on 18 Feb 2010 at 12:31