You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Mike Kienenberger <mk...@gmail.com> on 2014/03/21 16:47:18 UTC
3.2 support for vertical inheritance and query flushing?
My primary client is once again considering switching from JPA to Cayenne.
The last time this was brought up back in 2010, the lack of full
vertical inheritance support was an issue, and there was also the
question of handling JPA flush calls.
When I looked at the 3.0 docs, it seems like we now support vertical
inheritance fully, although I haven't tried it.
I don't enable flushing, but one of our programmers here flushes every
query, so if we were going to convert over to Cayenne, this would have
to be necessary. I'm not entirely certain how that would work in
Cayenne, although I thought someone said something about using
external transactions to make this happen. A google search on
cayenne flushing didn't turn up anything, and I know that the idea of
automatically flushing sql isn't a good fit with Cayenne.
Re: 3.2 support for vertical inheritance and query flushing?
Posted by Mike Kienenberger <mk...@gmail.com>.
On Tue, Apr 1, 2014 at 5:54 AM, Andrus Adamchik <an...@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!
Re: 3.2 support for vertical inheritance and query flushing?
Posted by Andrus Adamchik <an...@objectstyle.org>.
Sorry for delayed reply. VI is supported, although there were a few nasty bugs. In 3.2 we’ve removed a big source of related instability - “runtime” ObjRelationships. I hope this fixed most of it, but can’t guarantee that it fixes everything.
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;
}
}
);
Andrus
On Mar 21, 2014, at 6:47 PM, Mike Kienenberger <mk...@gmail.com> wrote:
> My primary client is once again considering switching from JPA to Cayenne.
>
> The last time this was brought up back in 2010, the lack of full
> vertical inheritance support was an issue, and there was also the
> question of handling JPA flush calls.
>
> When I looked at the 3.0 docs, it seems like we now support vertical
> inheritance fully, although I haven't tried it.
>
> I don't enable flushing, but one of our programmers here flushes every
> query, so if we were going to convert over to Cayenne, this would have
> to be necessary. I'm not entirely certain how that would work in
> Cayenne, although I thought someone said something about using
> external transactions to make this happen. A google search on
> cayenne flushing didn't turn up anything, and I know that the idea of
> automatically flushing sql isn't a good fit with Cayenne.
>