I don't know what you are using to support jta and connection management. In order to use jta + a non-xa-datasource you need a connection manager that knows how to do this and it needs to be configured properly. The geronimo connection manager does this but I don't know if its installed secretly in the aries jta support.
If you use an xa datasource you'll still only get one phase commit since there is only one participant, so if the driver is written reasonably it should be as fast as a non-xa datasource. (the "start transaction" xa message would be replaced by "auto commit off" for a non-xa datasource. Of course this might not result in a message to the server, depending on how the driver is written). david jencks On Feb 24, 2014, at 5:00 AM, Dutertry Nicolas <[email protected]> wrote: > Hi, > > I am trying to use transactions (JTA) and JPA with Aries blueprint but I did > not manage to make it work. > > I don't want to use XA datasource because I only access a single database. So > In my JPA persistence.xml file I have something like : > <persistence-unit name="test"> > > <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/testdb)</jta-data-source> > ... > > My blueprint.xml contains : > <bean id="personService" > class="test.service.impl.PersonServiceImpl"> > <tx:transaction method="*" value="Required"/> > <jpa:context property="entityManager" unitname="test"/> > </bean> > > I have written a test to check transaction's rollback, using a transactional > method like the following : > > public class PersonServiceImpl implements PersonService { > ... > public void createPerson(Person person) { > entityManager.persist(person); > entityManager.flush(); > > throw new RuntimeException("exception"); > } > } > > I was expecting that the created person would not be written to the database > after calling "createPerson" because of the Exception, but it is not the case > ! The person object is persisted in the database. > It appears that the underlying JDBC Connection has an autocommit property set > to "true", so rollback is impossible. I thought transaction manager would > take care of JDBC connection autocommit, but it is not the case. > > The result is the same with OpenJPA and Hibernate. > > Am I missing something related to JTA ? > > Thanks for your help. > > -- > Nicolas Dutertry > HR Access - http://www.hraccess.com > >
