I am using karaf 3.0.3 and the following Hibernate bundles:
161 | Active | 80 | 4.2.12.Final | hibernate-core
162 | Active | 80 | 4.2.12.Final | hibernate-entitymanager
172 | Active | 80 | 4.2.12.Final | hibernate-osgi
With this set-up I cannot get a transaction roll-back to work, although I can deploy the exact same components (JPA DAOs, service layer etc) as a standalone Spring application, and I see roll-backs performed correctly.
What are the gotchas when trying to get transactions to work successfully with OSGI/hibernate?
- is it something to do with cross-bundle transactions? (My DAOs and service layer are in separate bundles)
If I get not replies here, I will update with more specific information, but first I want to see if this is a common problem with OSGi/hibernate/jpa.
edit after user2007829's comment:
The DAOs extend Spring's JpaRepository
, and the service layer method is annotated with Spring's @Transactional
. I believe in this setup, auto commit should be implicitly off, and the standalone spring app set-up is working as expected. Is that wrong?
How should the persistence unit XML file differ in the OSGI case? Right now the only difference is that the transaction-type is JTA in the karaf case, and I have a declaration like this:
<jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/my-datasource)</jta-data-source>