I'm trying to set an existing datasource into an EntityManager using:
Code:
Ejb3Configuration cfg = new Ejb3Configuration();
cfg.addProperties(hibernateProperties);
cfg.setDataSource(dataSource);
return cfg.createEntityManagerFactory().createEntityManager();
The DataSource is configured via Spring to use a org.springframework.jdbc.datasource.DataSourceTransactionManager and a Transaction is properly started on the DataSource before I call entityManager.persist(cust).
But I always get a
Code:
javax.persistence.TransactionRequiredException: no transaction is in progress
, even if I start the transactions manually before the call.
How exactly does
org.hibernate.ejb.AbstractEntityManagerImpl.checkTransactionActive(AbstractEntityManagerImpl.java:123) perform the check, that it is inside a running Transaction?! Do I need a special TransactionManager for this to work?
Thx for any help
stf