cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <mkien...@gmail.com>
Subject Re: 3.2 support for vertical inheritance and query flushing?
Date Tue, 01 Apr 2014 12:14:00 GMT
On Tue, Apr 1, 2014 at 5:54 AM, Andrus Adamchik <andrus@objectstyle.org> wrote:
> I don't think we've ever used the term "flushing", so Google won't show it. But transaction
control is definitely there. If I understand this correctly (and translating to Cayenne terms),
you need a way to have an open transaction (container managed, or managed in your code) and
do multiple commits within this transaction, with a single atomic rollback. This is doable
in Cayenne of course. Here is manual example using 3.2 (there's more verbose API that does
it in the older versions) :
>
> serverRuntime.performInTransaction(new TransactionalOperation<SomeResult>() {
>        public SomeResult perform() {
>
>           // this will be a flush
>           context1.commitChanges();
>
>           // this will be another flush
>           context2.commitChanges();
>
>           return someResult;
>        }
>    }
> );

In JPA, the flush happens right before a query.

So to make this work similar to JPA and transparently, we would need
to create a DataChannelFilter, and if we are in flush mode in onQuery,
then execute a commit on our originating query.   That actually seems
pretty easy.

And the transaction management itself seems simple -- bound to a
thread.   The only non-obvious part is the final commit, but for JPA
we've already had to use beginTopLevelTransaction/beginTransacton
methods to differentiate between these two situations.

http://cayenne.apache.org/docs/3.0/understanding-transactions.html

Thanks!

Mime
View raw message