【发布时间】:2015-10-09 17:43:48
【问题描述】:
我正在尝试配置camel jpa组件,当我运行测试用例时,我收到了这个错误
“org.apache.openjpa.persistence.InvalidStateException:此代理未配置为使用托管事务。”
但如果我不使用任何事务管理器,它会使用默认的,一切顺利
我的配置
`@JndiBind("jpa")
@Provides*/
@Singleton
public JpaComponent getJpa(JpaVendorAdapter vendorAdapter){
JpaComponent jpa = new JpaComponent();
LocalEntityManagerFactoryBean fBean = new LocalEntityManagerFactoryBean();
fBean.setJpaVendorAdapter(vendorAdapter);
fBean.setPersistenceUnitName("camel");
fBean.afterPropertiesSet();
EntityManagerFactory entityManagerFactory = fBean.getNativeEntityManagerFactory();
JpaTransactionManager txMgr = new JpaTransactionManager();
txMgr.setEntityManagerFactory(entityManagerFactory);
jpa.setEntityManagerFactory(entityManagerFactory);
jpa.setTransactionManager(txMgr);
return jpa;
}`
【问题讨论】:
标签: java hibernate jpa apache-camel openjpa