[appengine-java] Checking if I understand transactions correctly
I am writing some code that needs to do a rollback on a secondary object/table should the transaction fail, I believe this can be done via entity groups, however I am not sure if this is how it would be implemented. I have written some sample code to check if what I would be doing is correct? Would the following code ensure the Account object is never updated if the insert of the TransactionRecord object fails. public void addTransaction(String account, Double value, String description, Date date) throws EntityNotFoundException { DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); int retries = 3; while (true) { Transaction txn = datastore.beginTransaction(); try { // Update the bank balance Key key = KeyFactory.createKey(Account, account); Entity e = datastore.get(key); Double balance = (Double) e.getProperty(balance); balance += value; e.setProperty(balance, value); datastore.put(e); // Record transaction details Entity d = new Entity(TransactionRecord, key); d.setProperty(account_key, key); d.setProperty(date, date); d.setProperty(value, value); d.setProperty(description, description); txn.commit(); break; } catch (ConcurrentModificationException e) { if (retries == 0) throw e; --retries; } finally { if (txn.isActive()) txn.rollback(); } } } Thanks for any feedback! -- 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.
[appengine-java] Would the following create problems for me in Google app engine?
I have a Java application that has approximately 100 users. In this application there is a table that would have the equivalent of 100,000 entities added per day, ie 100 users each doing 1000 inserts per day. From time to time I will need to output a CSV file that shows one months worth of entries for a particular user, ie would result in a file with 30,000 entries. If I understand correctly, The entities would be given an anscestor record to allow querying the transactions by user, and then filter them by month. Am I going to have timeout issues with querying by user+month, and for in the case where I need to export a month's worth of data? Any feedback much appreciated! -- 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.
[appengine-java] Question about accessing child objects when sharding
I am just learning JDO and GAE, and have gotten myself very stuck on this. I have gone from having just public class Article { ... } To now also having a parent: public class ArticleCollection { private long count private SetArticle articles; } However after doing this, the following code to fetch an article by id no longer works. How do I uniquely identify an object? Article article = (Article)pm.getObjectById(KeyFactory.createKey(Article.class.getName(), id)); Any help much appreciated! -- 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-j...@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.
[appengine-java] Question about accessing child objects when sharding
I am just learning JDO and GAE, and have gotten myself very stuck on this. I have gone from having just public class Article { ... } To now also having: public class ArticleCollection { return (Article)pm.getObjectById(KeyFactory.createKey(Article.class.getName(), id)); -- 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-j...@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.