Thursday, March 13, 2014

JPA JDO Java Persistence Tips The Year In Review

If you’re developing a Java application on App Engine you probably already know that you can use JPA and JDO, both standard Java persistence APIs, to interact with the datastore. What you may not know, and what I’m here to point out, is that for the past few months I’ve been accumulating a collection of practical, real-world examples that can help you take full advantage of these powerful APIs.



In episode one I put together a working example of an owned, bidirectional, one-to-many relationship and demonstrated how you can persist child objects just by associating them with parent objects. In episode two I demonstrated how to perform a batch get by issuing a query that only filters on the primary key property of your model object. In episode three I explored the exciting world of “transparent persistence,” explaining how you can modify the persistent state of objects without making any explicit calls to repersist them. In episode four I issued a keys-only query and got the results back crazy-fast because the datastore skipped the extra scan that turns keys into full-fledged entities. And in episode five I demonstrated how serialized fields can help you store arbitrary objects in the datastore.



After episode five I got a little bit tired, but there was still so much more to say, so I pressed on.



In episode six I powered through a discussion of long-running transactions and unearthed the ancient secret of how you can use optimistic locking to prevent users from updating stale data. In episode seven I explained how using unindexed properties can speed up your writes and save you valuable CPU time. In episode eight I attempted (cautiously) to blow your mind with a solution for case-insensitive queries. And finally, in episode nine, mere hours after releasing support for != and IN query operators in the SDK, I dove under the hood of these operators to help you understand their performance characteristics.



Many of these topics were inspired by questions from you, our users, so if there are topics you’d like to see covered in the coming year please let me know via the forum. As long as you keep reading and asking questions, I’ll keep writing.



Related Posts by Categories

0 comments:

Post a Comment