[appengine-java] Filtering by Date using the Datastore Low Level API
Good Evening Everyone, I am working on creating an event calendar type of page and am having trouble using the low level API and applying a filter to select events that occur in the future. The data that I am selecting has a property of "display_until" that holds a date in -mm-dd hh:mm:ss format. To select future events I started with the following code: SimpleDateFormat formatter; formatter = new SimpleDateFormat("-mm-dd hh:mm:ss"); Date date = new Date(); String query_date = formatter.format(date); query.addSort("display_until", Query.SortDirection.ASCENDING); query.addFilter("display_until", com.google.appengine.api.datastore.Query.FilterOperator.GREATER_THAN, query_date); When I ran this code it did select future events, but not all of them. Currently I have some 2009 and some 2010 events. It selected the 2010 events, but not the December 2009 events. Anyone have any suggestions for how I can select all of the future events? Thanks, Doug -- 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] Re: Filtering by Date using the Datastore Low Level API
Correcting the SimpleDateFormat solved the problem. Thank you for catching that! Doug On Nov 27, 5:26 am, m seleron wrote: > Hi, > > Though it might be unrelated. > I think that Date and Time Patterns of SimpleDateFormat is [MM] Month > in year [mm] Minute in hour. > > thanks. > > On 11月27日, 午後7:22, dflorey wrote: > > > > > The filter will just do string comparison (how should it know that you > > are comparing dates??) > > To get proper sorting/filtering just store the date as time in millis > > and it will work. > > > Cheers, > > Daniel > > > On 27 Nov., 04:25, Doug wrote: > > > > Good Evening Everyone, > > > > I am working on creating an event calendar type of page and am having > > > trouble using the low level API and applying a filter to select events > > > that occur in the future. The data that I am selecting has a property > > > of "display_until" that holds a date in -mm-dd hh:mm:ss format. > > > > To select future events I started with the following code: > > > SimpleDateFormat formatter; > > > formatter = new SimpleDateFormat("-mm-dd hh:mm:ss"); > > > Date date = new Date(); > > > String query_date = formatter.format(date); > > > > query.addSort("display_until", > > > Query.SortDirection.ASCENDING); > > > query.addFilter("display_until", > > > com.google.appengine.api.datastore.Query.FilterOperator.GREATER_THAN, > > > query_date); > > > > When I ran this code it did select future events, but not all of > > > them. Currently I have some 2009 and some 2010 events. It selected > > > the 2010 events, but not the December 2009 events. > > > > Anyone have any suggestions for how I can select all of the future > > > events? > > > > Thanks, > > > Doug -- 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] Re: HIPAA compliance
>From reading the Google Health FAQ I think the answer to your question is no, but they don't need to be. Is Google Health covered by HIPAA? Unlike a doctor or health plan, Google Health is not regulated by the Health Insurance Portability and Accountability Act (HIPAA), a federal law that establishes data confidentiality standards for patient health information. This is because Google does not store data on behalf of health care providers. Instead, our primary relationship is with you, the user. Under HIPAA, you have a right to obtain a copy of your medical records. If you choose to use Google Health, we'll help you store and manage your medical records online. Although Google Health is not covered by HIPAA, we are committed to protecting your privacy. Our Google Health privacy policy governs what information Google Health collects and how we use it, and any violation of that policy can be enforced by the Federal Trade Commission, which takes action against companies that engage in unfair and deceptive trade practices -- including violations of their privacy policies. On Jan 3, 11:17 am, Pion wrote: > http://www.slideshare.net/bess.ho/google-health-architecture-api > (slide 28) shows that Google Health is using Google App Engine. > > Is Google App Engine HIPAA (Health Insurance Portability and > Accountability Act -http://en.wikipedia.org/wiki/HIPAA) compliance ? -- 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] Datastore Reads
Good Morning, I am working to tune my application to make the most efficient use resources. Over the last several days I have been trying to reduce the number of 'datastore reads' that are needed, but I have been having trouble determining what a datastore read is. My initial assumption was that it was like a write in that each item you read from the datastore was a read, but I have reduced the number of 'rows' of data that I am reading by over half and there wasn't any change in the datastore reads. I am now wondering if a datastore read is more like a fetch from a database where in a single fetch you could be getting 1 or more rows of data. So, do anyone know what a datastore read is or can you point me in the right direction for documentation on this? Thanks, Doug -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine-java/-/RnvUDZnGnyMJ. 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] Java 5 and Remote API
Good Morning, I am trying to use the remote API to access the datastore in a Java 5 envirotment. Currently I am receiving the error below when trying to build the application. Is there a way to get a Java 5 verions of the appengine-api, appengine-remote-api, and appengine-tools.api jars? "class file has wrong version 50.0, should be 49.0" Thanks, Doug -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine-java/-/1Zjug3EggJ8J. 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] Re: Any inputs for How to use the DataStore for Java?
Those are all great references indeed. However, I'm still stumped on this one which should be basic. Using the Low Level API, I still cannot why String Properties break on special characters. thisEntity.setProperty("stringDescription" ,"Save 20% Off anything in store"); A little help on how to (convert?) and store (then get...) Strings containing non-alphanumeric characters with LLAPI? Many Thanks Doug -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine-java/-/Whb8noU7rZMJ. 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] Support of Java Keystore Files for SSL Connections
Hello All, Is there a way in GAE to access certificates that are stored in Java Keystore files and then have GAE use those certificates when making a connection to call a web service? I can do this outside of GAE by specifying the location of keystore file using 'System.setProperty("javax.net.ssl.keyStore","C:\\myKeys.jks");' and then specifying the keystore password using 'System.setProperty("javax.net.ssl.keyStorePassword","x");' I have been successful in calling other web services from GAE. I am just unsure how to tell GAE to use specific SSL certificates in making the connection. Thanks, Doug -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine-java/-/J0oa8lqe0ckJ. 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] Delete using low-level API
Good Morning, If I have the key and/or ID/name of a datastore object how can I delete it using the low-level API? I have looked though the java doc, but have not been able to find a delete method. Thanks, Doug -- 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] Re: Delete using low-level API
I think I found it. the delete method is in DatastoreService. Doug -- 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.
Re: [appengine-java] GAE deployment failure
I have the same issue. It started about an hour ago. Anyone have any ideas how to resolve? Doug -- 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] Task Queue API Update
Good Afternoon All, I am working to convert from the Task Queue Labs API to the non-labs API version. I am finding it slightly more difficult than I initially anticipated. It appears that how I was adding tasks to the queue is not compatible with the non-labs API. If I just update the imports to bring in the new API I get the error “The method url(String) is undefined for the type TaskOptions.Builder”. I have provide some example of my code below, if anyone else has converted can you give me some guidance on what I am doing wrong? Current code, using the Labs API: *import* *com.google.appengine.api.labs.taskqueue.Queue*; *import* *com.google.appengine.api.labs.taskqueue.QueueFactory*; *import* *com.google.appengine.api.labs.taskqueue.TaskOptions*; *import* *com.google.appengine.api.labs.taskqueue.TaskOptions.Method*; *import* *com.google.appengine.api.labs.taskqueue.TaskOptions.Builder*.*; … Queue add_queue = QueueFactory.getQueue("add"); … for (int i = 1; i < Item_counter; i++) { add_queue.add(TaskOptions.Builder.url("/add?item="+ItemURL[i]).method(Method.GET)); } Code using the non-Labs API import com.google.appengine.api.taskqueue.Queue; import com.google.appengine.api.taskqueue.QueueFactory; import com.google.appengine.api.taskqueue.TaskOptions; import com.google.appengine.api.taskqueue.TaskOptions.Method; import static com.google.appengine.api.taskqueue.TaskOptions.Builder.*; TaskOptions TOdefault = com.google.appengine.api.taskqueue.TaskOptions.Builder.withDefaults(); … for (int i = 1; i < Item_counter; i++) { TaskOptions TO = new TaskOptions(TOdefault); TO.url("/add"); TO.param("item", itemURL[i]); TO.method(Method.GET); add_queue.add(TO); } The new code compiles and will “run”, but I get all kinds of null pointer exceptions from the tasks when they try to run. If I switch back to the labs API it works perfectly. Can anyone help me understand what I need to do to either get my original code to work with the new API and/or what I did incorrectly with the updated code? Thanks, Doug -- 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] Re: how to query TaskQueue for count of running/pending tasks?
There was another thread on this same topic a few months back. I am not able to find it right now, but I believe that I remember that someone was using URL Fetch to fetch "https://appengine.google.com/queues?&app_id=&version_id=xx"; and then parsing the page to determine the number of tasks on each queue. I don't recall how they were handling authentication. Doug -- 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] Data via FTP
Good Afternoon All, In App Engine is there any way to get a file via FTP or have a file FTPed to the application? I wanted to be able to get a feed of data into my application from a vendor that only supports sending data via FTP. I did some initial searching and it appears that there is no way to either receive the file via FTP into an application or get a file via FTP. Any suggestions? I have a Google Apps account, but I don's see anything that I could use in combination with App Engine to make this work. I appreciate any help and/or ideas that anyone has. Thanks, Doug -- 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.
Re: [appengine-java] Data via FTP
Thank you. I stared the item. This would be a great feature to add. Doug -- 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] Datastore and Polymorphic support getObjectByID(Parent.class, childKey)
I'm trying to model a polymorphic relationship in JDO, List where each GameRound could be either a TextRound or PictureRound. I've followed the documentation and modeled the association as a List as described: http://code.google.com/appengine/docs/java/datastore/relationships.html#Polymorphic_Relationships // ... imports ... @PersistenceCapable public class Chef { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key; @Persistent private Key favoriteRecipe; } Here is my Game object: @PersistenceCapable public class Game { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key; @Persistent private List rounds = new ArrayList(); ... } @PersistenceCapable @Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE) public class GameRound { ... } @PersistenceCapable public class SentenceRound extends GameRound { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key; ... } @PersistenceCapable public class PictureRound extends GameRound { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key; ... } The trouble is in my Game object I iterate through the rounds and try to do a persistenceManager.getObjectById(GameRound.class, key) and I get the following exception: WARNING: /viewGames.jsp javax.jdo.JDOFatalUserException: Exception converting SentenceRound(7) to an internal key. at org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManager.getObjectById(DatastoreJDOPersistenceManager.java: 68) at org.apache.jsp.viewGames_jsp._jspService(viewGames_jsp.java:121) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94) What's the proper way to retrieve a polymorphic key relationship (for example how would you do it in the Appengine Chef example?). My only other option is to model the relationship as mutually exclusive properties of the GameRound (and manage that in my application logic). @PersistenceCapable @Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE) public class GameRound { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key; //Model relationships as optional components because JDO and Appengine don't support //Polymorphic relationships well. @Persistent private SentenceRound sentenceRound; @Persistent private PictureRound pictureRound; ... } -- 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] Use BlobstoreService and ImageService to upload/serve images drawn from an HTML5 canvas Paintweb JS Library
I'm working on an Appengine application in Java that allows users to upload images drawn through an HTML5 canvas library called PaintWeb (http://code.google.com/p/paintweb/). Currently I have a servlet that receives the XMLHttpRequest POST from the paintweb javascript library as a formencoded image. 1. Paintweb.js library sends XMLHttpRequest POST send = 'dataURL=' + encodeURIComponent(ev.dataURL), headers= {'Content-Type': 'application/x-www-form- urlencoded'}; 2. A custom servlet decodes the form encoded image data as a blob and stores that in the Datastore with an associated Drawing entity 3 Custom servlet serves the Blob's in the datastore as ContentType("image/png") I'm curious if I can use the new BlobstoreService and ImageService features to upload my HTML5 canvas images and serve them as pure Blobs (as shown in this tutorial http://ikaisays.com/2010/09/08/gwt-blobstore-the-new-high-performance-image-serving-api-and-cute-dogs-on-office-chairs/) According to the documentation (http://code.google.com/appengine/docs/ java/blobstore/overview.html#Uploading_a_Blob) it seems like the major stopping point is that I need to POST a form with: Which I don't think is possible from Paintweb. Possibly a work around would be if there was some way on the server side to store a blob in the Blobstorage (instead of the datastore) so that you could reap the benefits of not using your CPU quota to serve images. -- 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] Re: Use BlobstoreService and ImageService to upload/serve images drawn from an HTML5 canvas Paintweb JS Library
Is it possible or even a good idea to use the Appengine URL Fetch service and forward the image blob upload to the Blobstorage "createUploadURL()" from the server side. http://code.google.com/appengine/docs/java/urlfetch/usingjavanet.html It seems like it could be possible, but not sure it would save me resources in the long run (the images are simple small drawings that could be viewed many many more times than the upload time so I feel like I'd get benefit storing/serving from the BlobstoreService. On Sep 19, 3:02 pm, Doug Daniels wrote: > I'm working on an Appengine application in Java that allows users to > upload images drawn through an HTML5 canvas library called PaintWeb > (http://code.google.com/p/paintweb/). > > Currently I have a servlet that receives the XMLHttpRequest POST from > the paintweb javascript library as a formencoded image. > > 1. Paintweb.js library sends XMLHttpRequest POST > send = 'dataURL=' + encodeURIComponent(ev.dataURL), > headers = {'Content-Type': 'application/x-www-form- > urlencoded'}; > > 2. A custom servlet decodes the form encoded image data as a blob and > stores that in the Datastore with an associated Drawing entity > > 3 Custom servlet serves the Blob's in the datastore as > ContentType("image/png") > > I'm curious if I can use the new BlobstoreService and ImageService > features to upload my HTML5 canvas images and serve them as pure Blobs > (as shown in this > tutorialhttp://ikaisays.com/2010/09/08/gwt-blobstore-the-new-high-performance...) > > According to the documentation (http://code.google.com/appengine/docs/ > java/blobstore/overview.html#Uploading_a_Blob) it seems like the major > stopping point is that I need to POST a form with: > > > Which I don't think is possible from Paintweb. > > Possibly a work around would be if there was some way on the server > side to store a blob in the Blobstorage (instead of the datastore) so > that you could reap the benefits of not using your CPU quota to serve > images. -- 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] Sharded Counters in Java not using Transactions?
I'm going through the Sharded Counters example in Java: http://code.google.com/appengine/articles/sharding_counters.html I have a question about the implementation of the increment method. In python it explicitly wraps the get() and increment in a transaction. In the Java example it just retrieves it and sets it. I'm not sure I fully understand the Datastore and transactions but it seems like the critical update section should be wrapped in a datastore transaction. Am I missing something? Original code: public void increment() { PersistenceManager pm = PMF.get().getPersistenceManager(); Random generator = new Random(); int shardNum = generator.nextInt(NUM_SHARDS); try { Query shardQuery = pm.newQuery(SimpleCounterShard.class); shardQuery.setFilter("shardNumber == numParam"); shardQuery.declareParameters("int numParam"); List shards = (List) shardQuery.execute(shardNum); SimpleCounterShard shard; // If the shard with the passed shard number exists, increment its count // by 1. Otherwise, create a new shard object, set its count to 1, and // persist it. if ( Transactional code: public void increment() { PersistenceManager pm = PMF.get().getPersistenceManager(); Random generator = new Random(); int shardNum = generator.nextInt(NUM_SHARDS); try { Query shardQuery = pm.newQuery(SimpleCounterShard.class); shardQuery.setFilter("shardNumber == numParam"); shardQuery.declareParameters("int numParam"); List shards = (List) shardQuery.execute(shardNum); SimpleCounterShard shard; // If the shard with the passed shard number exists, increment its count // by 1. Otherwise, create a new shard object, set its count to 1, and // persist it. if (shards != null && !shards.isEmpty()) { Transaction tx = pm.currentTransaction(); try { tx.begin(); //I believe in a transaction objects need to be loaded by ID (can't use the outside queried entity) Key shardKey = KeyFactory.Builder(SimpleCounterShard.class.getSimpleName(), shards.get(0).getID()) shard = pm.getObjectById(SimpleCounterShard.class, shardKey); shard.setCount(shard.getCount() + 1); tx.commit(); } finally { if (tx.isActive()) { tx.rollback(); } } } else { shard = new SimpleCounterShard(); shard.setShardNumber(shardNum); shard.setCount(1); } pm.makePersistent(shard); } finally { pm.close(); } } } -- 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] Re: Sharded Counters in Java not using Transactions?
I posted the question on Stackoverflow and the consensus is that it should be wrapped in a transaction. http://stackoverflow.com/questions/3782296/java-google-appengine-sharded-counters-without-transactions I also opened an Appengine issue (is this the right way to report issues in documentation?): http://code.google.com/p/googleappengine/issues/detail?id=3778&q=sharded&colspec=ID%20Type%20Status%20Priority%20Stars%20Owner%20Summary%20Log%20Component On Sep 21, 12:24 pm, Doug Daniels wrote: > I'm going through the Sharded Counters example in > Java:http://code.google.com/appengine/articles/sharding_counters.html > > I have a question about the implementation of the increment method. In > python it explicitly wraps the get() and increment in a transaction. > In the Java example it just retrieves it and sets it. I'm not sure I > fully understand the Datastore and transactions but it seems like the > critical update section should be wrapped in a datastore transaction. > Am I missing something? > > Original code: > public void increment() { > PersistenceManager pm = PMF.get().getPersistenceManager(); > > Random generator = new Random(); > int shardNum = generator.nextInt(NUM_SHARDS); > > try { > Query shardQuery = pm.newQuery(SimpleCounterShard.class); > shardQuery.setFilter("shardNumber == numParam"); > shardQuery.declareParameters("int numParam"); > > List shards = > (List) shardQuery.execute(shardNum); > SimpleCounterShard shard; > > // If the shard with the passed shard number exists, increment > its count > // by 1. Otherwise, create a new shard object, set its count to > 1, and > // persist it. > if ( > > Transactional code: > > public void increment() { > PersistenceManager pm = PMF.get().getPersistenceManager(); > > Random generator = new Random(); > int shardNum = generator.nextInt(NUM_SHARDS); > > try { > Query shardQuery = pm.newQuery(SimpleCounterShard.class); > shardQuery.setFilter("shardNumber == numParam"); > shardQuery.declareParameters("int numParam"); > > List shards = > (List) shardQuery.execute(shardNum); > SimpleCounterShard shard; > > // If the shard with the passed shard number exists, increment > its count > // by 1. Otherwise, create a new shard object, set its count to > 1, and > // persist it. > if (shards != null && !shards.isEmpty()) { > Transaction tx = pm.currentTransaction(); > > try { > tx.begin(); > //I believe in a transaction objects need to be > loaded by ID (can't > use the outside queried entity) > Key shardKey = > KeyFactory.Builder(SimpleCounterShard.class.getSimpleName(), > shards.get(0).getID()) > shard = pm.getObjectById(SimpleCounterShard.class, > shardKey); > shard.setCount(shard.getCount() + 1); > tx.commit(); > } finally { > if (tx.isActive()) { > tx.rollback(); > } > } > > } else { > shard = new SimpleCounterShard(); > shard.setShardNumber(shardNum); > shard.setCount(1); > } > > pm.makePersistent(shard); > } finally { > pm.close(); > } > } > > > > > > > > } -- 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.