Hibernate OGM Neo4j - 无法访问 TransactionManager

Hibernate OGM Neo4j -Unable to access TransactionManager

我尝试使用 Neo4j 作为 No-SQL-Databaseing 构建一个 JSF WebApplication。我想通过 Hibernate 访问 Neo4j。

我的依赖项是

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.hibernate.ogm</groupId>
            <artifactId>hibernate-ogm-bom</artifactId>
            <version>5.0.1.Final</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.hibernate.ogm</groupId>
        <artifactId>hibernate-ogm-neo4j</artifactId>
    </dependency>

我的实体如下所示

@Entity
public class Person implements Serializable {

 private static final long serialVersionUID = 1L;

 @Id
 @GeneratedValue(generator = "uuid")
 @GenericGenerator(name = "uuid", strategy = "uuid2")
 private String id;

 private String name;

 private Double age;

 @OneToMany(fetch = FetchType.EAGER, mappedBy = "owner", cascade = CascadeType.PERSIST)
 private Set<Car> cars = new HashSet<>();
 ...

我把它们保存在下面class

@Stateless
public class StorageManager {

 @PersistenceContext(unitName = "neo4j")
 private EntityManager em;

 public void savePerson(Person p) {
    em.persist(p);
 }

 public void saveCar(Car c){
    em.persist(c);
 }

 public void save(String personName, Double personAge, String carName) {
    Person person = new Person(personName, personAge);
    Car car = new Car(carName);
    car.setOwner(person);
    person.getCars().add(car);
    em.persist(person);
 }

我的坚持单位

<persistence-unit name="mongo-ogm" transaction-type="JTA">
    <provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
    <class>entities.Person</class>
    <class>entities.Car</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>

    <properties>
        <property name="hibernate.ogm.datastore.provider" value="neo4j_embedded" />
        <property name="hibernate.ogm.neo4j.database_path" value="C:\Users\phe\Documents\Neo4j\sample" />
    </properties>
</persistence-unit>

当我在我的 Wildlfy 9 上部署 WebApp 并想要保存数据时,我得到一个异常

org.hibernate.resource.transaction.backend.jta.internal.JtaPlatformInaccessibleException: Unable to access TransactionManager or UserTransaction to make physical transaction delegate

网上查了无果。只有几个教程。我已经尝试过使用和不使用 transaction-type="JTA" .

你有什么想法吗?

我找到了解决方案。当我部署到 Wildfly 时,我可以将以下内容添加到我的持久性单元中。

<property name="hibernate.transaction.jta.platform" value="JBossAS" />

这对我有用。