I am trying to integrate together JOTM and Hibernate EntityManager to test my EJBs in a transactional manner environment but out-of-container.
My test looks like the following:
- Start JOTM
- Put JOTM's UserTransaction into JNDI
- Create and configure StandardXADataSource
- Put the DataSource into JNDI
- Configure hibernate and create EMF
- Create an EM
- Begin a transaction
- Join the transaction in EM
- Store an entity
- Verify it is stored
- Rollback the transaction
- Check the database for the count of records
- Tear everything down
Here is what my code looks like: http://pastebin.com/m22a9f6b
Here is the logging output: http://pastebin.com/m6da9383a
The test fails on step 12 (line 121).
As you can see, even though I have roll-backed the transaction, there is a record in the DB. Seems like transactions where not used at all and the record got through into the db.
Do you have any ideas how this could be happening and how to fix it?