0
我有在Java 8.5上運行的JPA(Hibernate 4.2)JavaEE 7的Web應用程序。我想避免在我的應用程序中使用EJB。當我試圖保持更改時,我得到javax.persistence.TransactionRequiredException:沒有PuId的活動事務。我希望websphere能夠管理交易。在野蠻8.0上一切正常。HIbernate 4.2沒有活動的事務處理PuId
我的persistence.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence version="2.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="org.jbpm.domain" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/MyApp</jta-data-source>
<class>Diagram</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.WebSphereExtendedJtaPlatform" />
<property name="hibernate.id.new_generator_mappings" value="false"/>
</properties>
</persistence-unit>
而且類這裏我真的想堅持的變化:
import javax.inject.Inject;
import javax.inject.Named;
import javax.transaction.Transactional;
@Transactional
@Named
class PersistentAssetStorage {
@Inject
private EntityManager em;
public long saveProcessDefinition(final Diagram diagram) {
em.persist(diagram);
}
}
您可以在完全支持Java EE 7的WebSphere Liberty概要文件8.5.5.6和更高版本上嘗試它。 – Gas 2016-04-25 14:34:26