> About this I must disagree.  Everything I've learned about the
> appengine datastore says that unless you specifically need
> transactions, you should avoid using parent entities.
>
> When any entity is written, the optimistic concurrency journal is
> maintained for the root of the entity group.  If you make writes all
> over a large entity graph, they will all contend for the same journal,
> diminishing throughput.

I stand corrected - I misunderstood the explanation about entity
groups in the GAE documentation.

>> This _is_ redundant since internally GAE stores the owner inside the
>> Key field. So we settled for the simplest solution, that was to make
>> visible the Key system used by GAE. It also makes getting by primary
>> key more efficient, since you don't have to pass the class.
>
> You completely lost me with this one.  What's more efficient?  Using
> the datastore Key class means you get no help from the compiler.  If
> you pass Key objects around through methods you can very quickly lose
> track of what those keys are supposed to point to!  The generic
> Key<MyEntity> may require a little more typing but it will
> significantly reduce the probability of bugs.

We are checking out the Key ancestor line while retrieving and storing
entities. As far as our experience went, this was the most common
source of bugs in our code, other than that we were fine. Of course
YMMV, and I can see your point.

> Objectify ofy1 = ObjectifyService.beginTransaction();
> Objectify ofy2 = ObjectifyService.beginTransaction();
>
> Foo foo = ofy1.get(Foo.class, 123);
> Bar bar = ofy2.get(Bar.class, 987);
>
> The transaction is bound to the object instance.  You can merrily work
> with ofy1 and ofy2 in separate transactions.

It's cleaner than the JDO alternative, but requires one Objectity
instance per transaction (or no transaction). We are doing it using
aspects (disclaimer: snapshot code):

@Transactional
public void put(Foo entity) {
   Transaction tx = transactionManager.beginTransaction();
   entityManager.put(tx, entity);
}

There is no need of commiting or rolling back, and you only need one
entityManager.

Different way of doing things, I will take a look at Objectify to see
what else I can learn :)

-- Nacho.
P.S.: hey GAE guys: can you add a datastore.getActiveTransactions()
method? We are storing the same info using a redundant ThreadLocal!
(GAE is doing the same, just make that information public :)

-- 
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.

Reply via email to