Hi Craig,
I am using the extended persistence context paradigm and I have configured
Spring Framework's transactions to use
org.springframework.orm.jpa.JpaTransactionManager
I inject the EntityManagerFactory into the JpaTransactionManager after grabbing
an EntityManager and storing it in a threadlocal for myself.
The EntityManagerFactory gives the transaction manager the same EntityManager -
presumably from a threadlocal internal to the EMF. Am I correct?
Preliminary prototyping shows that this works well.
Regards
Adam
Craig L Russell on 28/11/07 20:05, wrote:
Sorry it took so long to get back to you. According to Matthew Adams,
when using Spring:
See method retrieveTransactionSynchronizationRegistry() for the
particular JtaTransactionManager subclass that you are using; it's
protected in JtaTransactionManager, and subclasses (like
WebLogicJtaTransactionManager) can override it and make it public. That
should give the application access to the TSR that they need.
Does that help?
Craig
On Nov 14, 2007, at 5:07 AM, Adam Hardy wrote:
Patrick Linskey on 10/11/07 21:15, wrote:
Without anyone else's input on this, I'm going to look further down
this route:
providing OpenJPA with the means to get at the managed transactions
/ entity
managers.
Do you know whether this is OpenJPA functionality only or if it's
specified in
the EJB JPA specification? I'd like to be able to say that I can
swop OpenJPA
for any other JPA provider with only configuration changes necessary.
The JPA spec doesn't define how a persistence provider should go about
obtaining the JTA transaction. With OpenJPA, there are a number of
configuration-based means to set this up; I would expect the same to
be the case for other persistence providers.
In OpenJPA, you can do one of the following:
1. Specify a JNDI location where the TransactionManager can be found
2. Tell OpenJPA to use the TransactionSynchronizationManager, which
should be registered at java:comp/TransactionSynchronizationRegistry
per the Java EE 5 spec
3. Tell OpenJPA to use a special implementation of the
org.apache.openjpa.ee.ManagedRuntime interface, which you would need
to at least partially implement to provide access to the Spring
TransactionManager.
Does this make sense?
I'm currently looking at implementing my own
TransactionSynchronizationRegistry and populating it, putting it in
JNDI and so on.
Whether that will work is the big question. I'm searching the OpenJPA
source to see how it's accessed.
One thing that I keep wishing as I do this is that JTA was as modular
as JPA. I would just like to unbundle the transaction management from
the rest of Spring or the EJB container, and so far it looks like I'll
spend my whole day researching and trying it out.
Adam
Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:[EMAIL PROTECTED]
P.S. A good JDO? O, Gasp!