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