Hi,

Many thanks. I will make the changes according to your recommendations and test my application.

Regards,

Charles

On 19/11/10 10:50, Timothy Ward wrote:
Hi Charles,

I'm afraid that I had to return to the UK on Tuesday after doing my lab on 
Monday due to scheduling conflicts, so I'm no longer at Devoxx, but hopefully I 
can answer all your questions via the email lists.

The main changes you need to make to use container managed JPA are as follows:

1. Change the<jpa:unit unitname="camel" ... tag to be a<jpa:context ... tag.

2. Change the type of your setter to be an EntityManager, and remove any 
lifecycle management code (e.g. emf.createEntityManager(), 
em.joinTransaction(), em.close() etc)

3. If you were previously passing your EntityManager between objects then consider 
injecting them with a managed persistence context instead. There is no need to pass 
around the "current" EntityManager, as the container will ensure the correct 
one is used.

The changes shouldn't be too complicated to make, and should make your 
application code a bit shorter and more business focussed.

Regards,

Tim


----------------------------------------
Date: Thu, 18 Nov 2010 17:37:40 +0100
From: [email protected]
To: [email protected]
Subject: Re: How to translate Spring JPA into Aries JPA

Hi Timothy,

I'm at the DevoXX. So maybe we can discuss a little bit tomorrow. We
have a stand (FuseSource).

How can I configure the container-manager JPA as you tell me that I
configure it like Application-Manager JPA ?

Regards,

Charles

On 08/11/10 15:17, Timothy Ward wrote:
Hi,

It looks like you're trying to do Application-Managed JPA rather than 
container-managed JPA with this example (i.e. you want to have an 
EntityManagerFactory and manage the EntityManager lifecycle yourself).

In this case you can just inject the persistence unit directly into the bean 
that wants it with e.g.





This encompasses all of the integration with global transactions as well as the 
JPA injection via the setEntityManagerFactory method.



Managed transactions can be configured using the transactions namespace e.g.





This bean will have a "Required" transaction attribute for all public methods 
invoked from outside the bean.



These two concepts are often used together with container-managed persistence 
contexts (i.e you let the container manage the EntityManager lifecycle). There 
are examples of this in the Blog sample.








I hope this helps. If you'd like to put any of your experiences together it 
would be great to start building some better documentation for the Aries JPA 
component.

Regards,

Tim

----------------------------------------
Hi,

Do we have an example showing what we define like this in spring


class="org.springframework.transaction.support.TransactionTemplate">












class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">



but using Aries JPA and Aries Transaction now ?

Regards,

Charles M.
Apache ServiceMix, Camel and Karaf committer
                                        

Reply via email to