Hi,
Reading the docs for transactions:
http://code.google.com/appengine/docs/java/datastore/transactions.html
An example provided shows one way to make an instance of an object:
try {
tx.begin();
Key k = KeyFactory.createKey("SalesAccount", id);
try {
account = pm.getObjectById(Employee.class, k);
} catch (JDOObjectNotFoundException e) {
account = new SalesAccount();
account.setId(id);
}
...
When the above transaction gets executed, it will probably block all other write attempts on Account objects? I'm wondering because I'd like to have a user signup which checks for a username or email already in use:
tx.begin();
"select from User where mUsername == str1 LIMIT 1";
if (count > 0) {
throw new Exception("username already in use!");
}
"select from User where mEmail == str1 LIMIT 1";
if (count > 0) {
throw new Exception("email already in use!");
}
pm.makePersistent(user(username, email)); // ok.
tx.commit();
but the above would be even more time consuming I think, making an even worse bottleneck? Am I understanding what will happen correctly?
Thanks