You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by stéphane Lestoclet <st...@yahoo.fr> on 2011/09/11 16:41:05 UTC

Cayenne Transactions

Hi,


The Cayenne documentation states the following :

Chapter: Understanding Transactions
>It works either as a standalone mechanism, or in conjunction with another transaction framework, such as JTA or Spring..

Could you provide examples for both please ?

Actually, I am new to Apache Cayenne and I am trying to find a serious alternative to Hibernate.
Unfortunately, Spring does not provide a CayenneTransactionManager as for Hibernate, iBatis and JPA. This makes it difficult to show that
Cayenne integrates well with the famous integration framework which is Spring.

It would also be a very good idea to ship examples with Cayenne (JUnit Tests would be great) in order to show that Cayenne
can be actually used/integrated with other technologies.

Thanks in advance,

Re: Cayenne Transactions

Posted by Mike Kienenberger <mk...@gmail.com>.
At one point, there was a Spring with Cayenne example by Andrus.  Not
sure how dated it is now.

https://cwiki.apache.org/CAY/spring-integration-examples.html

On Sun, Sep 11, 2011 at 10:41 AM, stéphane Lestoclet
<st...@yahoo.fr> wrote:
> Hi,
>
>
> The Cayenne documentation states the following :
>
> Chapter: Understanding Transactions
>>It works either as a standalone mechanism, or in conjunction with another transaction framework, such as JTA or Spring..
>
> Could you provide examples for both please ?
>
> Actually, I am new to Apache Cayenne and I am trying to find a serious alternative to Hibernate.
> Unfortunately, Spring does not provide a CayenneTransactionManager as for Hibernate, iBatis and JPA. This makes it difficult to show that
> Cayenne integrates well with the famous integration framework which is Spring.
>
> It would also be a very good idea to ship examples with Cayenne (JUnit Tests would be great) in order to show that Cayenne
> can be actually used/integrated with other technologies.
>
> Thanks in advance,
>

Re: Cayenne Transactions

Posted by Malcolm Edgar <ma...@gmail.com>.
Please take a look at the example at the bottom of the page:

http://cayenne.apache.org/doc20/understanding-transactions.html

I use Cayenne in a fairly straight forward manner, and perform
transactions explicitly in code rather than using an AOP approach.

With regard to Spring integration, Cayenne does not actually need
Spring to fill in the gaps like HIbernate does.

regards Malcolm Edgar

On Mon, Sep 12, 2011 at 12:41 AM, stéphane Lestoclet
<st...@yahoo.fr> wrote:
> Hi,
>
>
> The Cayenne documentation states the following :
>
> Chapter: Understanding Transactions
>>It works either as a standalone mechanism, or in conjunction with another transaction framework, such as JTA or Spring..
>
> Could you provide examples for both please ?
>
> Actually, I am new to Apache Cayenne and I am trying to find a serious alternative to Hibernate.
> Unfortunately, Spring does not provide a CayenneTransactionManager as for Hibernate, iBatis and JPA. This makes it difficult to show that
> Cayenne integrates well with the famous integration framework which is Spring.
>
> It would also be a very good idea to ship examples with Cayenne (JUnit Tests would be great) in order to show that Cayenne
> can be actually used/integrated with other technologies.
>
> Thanks in advance,
>

RE: Cayenne Transactions

Posted by "Durchholz, Joachim" <Jo...@hennig-fahrzeugteile.de>.
On 14/09/11 9:15 PM, Durchholz, Joachim wrote:
>> dropping down to native SQL,
> 
> Moving to SQL will not be one of the changes you'll need to make.

Ah, I see I was being unclear.
I meant the places where the program drops down to raw SQL.

E.g. for importing data from other databases where the actual data never hits the JVM; it's just a series of bulk SQL. Cayenne shouldn't come into play, except I'll want a JDBC connection and I tend to let the ORM manage connections (no need to reinvent the wheel), which means I'll probably need to ask Cayenne for one.

And then there's always the utterly nonportable code.
Such as database process monitoring. I just completed a small management tool that allows shooting down Oracle sessions; the selling point here being that the list of eligible processes is limited to those started by my software.

> The Cayenne query API is powerful and easy to use.

Excellent :-)

Regards,
Jo

Re: Cayenne Transactions

Posted by Aristedes Maniatis <ar...@maniatis.org>.
On 14/09/11 9:15 PM, Durchholz, Joachim wrote:
> But getting rid of HQL, dropping down to native SQL, and changing all the Hibernate types to Cayenne types could require a lot of rewriting that don't improve the project in themselves; also, I do have some trepidation that I'll need to rework parts of the program's structure.

Moving to SQL will not be one of the changes you'll need to make. The Cayenne query API is powerful and easy to use.

Ari

-- 
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

RE: Cayenne Transactions

Posted by "Durchholz, Joachim" <Jo...@hennig-fahrzeugteile.de>.
> I think you misunderstood - there are 1..1 relationships in Cayenne of course. 

Phew.

> There's no one to one correspondence between Cayenne and Hibernate features :-)

Phew :-)))

(Some of Hibernate's features are massive misfeatures IMNSHO.)

Re my own status, I was forced to shelve the transition to Cayenne due to workforce constraints. But I'm still looking forward to eventually moving to it... and it will be interesting to see how much I'll have to rewrite in the end.
Not a loss for things that never quite worked anyway in Hibernate, most prominently session breakage recovery.
But getting rid of HQL, dropping down to native SQL, and changing all the Hibernate types to Cayenne types could require a lot of rewriting that don't improve the project in themselves; also, I do have some trepidation that I'll need to rework parts of the program's structure.

Well, I'll see. Hopefully this year, even :-)

Regards,
Jo

Re: Cayenne Transactions

Posted by Andrus Adamchik <an...@objectstyle.org>.
On Sep 14, 2011, at 12:18 PM, Durchholz, Joachim wrote:

>> if you are looking for 1..1 correspondence, there won't be one
> 
> Oh. That's one difference I missed.
> 
> We do have a one-to-one relationship, with one end optional.
> How does one deal with that in Cayenne?

I think you misunderstood - there are 1..1 relationships in Cayenne of course. 

There's no one to one correspondence between Cayenne and Hibernate features :-)

Andrus


RE: Cayenne Transactions

Posted by "Durchholz, Joachim" <Jo...@hennig-fahrzeugteile.de>.
> if you are looking for 1..1 correspondence, there won't be one

Oh. That's one difference I missed.

We do have a one-to-one relationship, with one end optional.
How does one deal with that in Cayenne?

> See other replies in this thread. I can only add that Cayenne is as mature as Hibernate,

Huh. I would avoid saying that - people coming here come because they're dissatisfied with Hibernate ;-)

Regards,
Jo

Re: Cayenne Transactions

Posted by Andrus Adamchik <an...@objectstyle.org>.
Hi there,

See other replies in this thread. I can only add that Cayenne is as mature as Hibernate, and has its own approaches to a set of persistence problems (so if you are looking for 1..1 correspondence, there won't be one). Cayenne most certainly can be and has been integrated with all kinds of frontend and IoC(DI) technologies, batch job processors, web services, etc. 

Usually it doesn't require a separate framework to do that :-) E.g. here is a typical "CayenneService" that I am mapping in a DI container of my app (based on 3.1 code) to provide the rest of the app with access to Cayenne. Showing it here in full as another 3.1 primer. As you see it is pretty thin:

public interface ICayenneService {

	void addListener(Object listener);

	void addFilter(DataChannelFilter filter);

	ObjectContext sharedContext();

	ObjectContext newContext();
}

public class CayenneService implements ICayenneService {

	private ObjectContext sharedContext;
	private ServerRuntime runtime;

	public CayenneService() {
		
		Module module = new Module() {
			
			@Override
			public void configure(Binder binder) {
 				// customize Cayenne internals here...
				binder.bind(QueryCache.class).toInstance(new OSQueryCache());
			}
		};

		// bootstrap one or more mappings, creating Runtime object...
		runtime = new ServerRuntime("cayenne-site.xml", ocModule);

 		// start a read-only shared context
		sharedContext = runtime.getContext();
	}

	@Override
	public void addListener(Object listener) {
		runtime.getDataDomain().getEntityResolver().getCallbackRegistry()
				.addListener(listener);
	}

	@Override
	public void addFilter(DataChannelFilter filter) {
		runtime.getDataDomain().addFilter(filter);
		addListener(filter);
	}

	@Override
	public ObjectContext sharedContext() {
		return sharedContext;
	}

	@Override
	public ObjectContext newContext() {
		return runtime.getContext();
	}
}

Andrus


On Sep 11, 2011, at 5:41 PM, stéphane Lestoclet wrote:
> Hi,
> 
> 
> The Cayenne documentation states the following :
> 
> Chapter: Understanding Transactions
>> It works either as a standalone mechanism, or in conjunction with another transaction framework, such as JTA or Spring..
> 
> Could you provide examples for both please ?
> 
> Actually, I am new to Apache Cayenne and I am trying to find a serious alternative to Hibernate.
> Unfortunately, Spring does not provide a CayenneTransactionManager as for Hibernate, iBatis and JPA. This makes it difficult to show that
> Cayenne integrates well with the famous integration framework which is Spring.
> 
> It would also be a very good idea to ship examples with Cayenne (JUnit Tests would be great) in order to show that Cayenne
> can be actually used/integrated with other technologies.
> 
> Thanks in advance,