OK, here is something that looks promising; 

http://squeeville.com/2009/01/30/add-a-unique-constraint-to-google-app-engine/

This shows a solution in python, but the concept is applicable to Java. 
 Basically, for the unique field, you create another database entity and 
derive a primary Key based on the unique field.  Since the database ensures 
uniqueness of a primary key, this means that we can atomically create and 
check the existence of this entity.   So my pseudocode might look like;

pm.currentTransaction.begin();
Object preexistingKey = pm.insert(new SecondaryKeyEntity("secondary key"));
pm.currentTransaction.commit();

//
// if we get here, then the previous transaction completed and
// no other process will be able to get to this section of the code
// using the same secondary key
//
pm.currentTransaction.begin();
pm.insert(new Entity("secondary key"));
pm.currentTransaction.commit().

Of course, you need to do something similar when you change the secondary 
key (for instance, if someone wants to update their email address).  Again, 
just attempt to create an 'SecondaryKeyEntity' with the new email address. 
 If that successes, then you can change the email address in the primary 
entity.  Remember to delete the old SecondaryKeyEntity after!!

I'll work on this over the weekend and post some code if I figure it out.  

In the mean time, if anyone has already done this, please let us know. 
 Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to