Hello,
I tried to connect to neo4j using JTA with 5.1.0.CR1 version from hibernate-ogm-neo4j but I could not do that.
I did the following configuration in persistence.xml
Code:
<?xml version="1.0"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="ogm-jpa-tutorial" transaction-type="JTA">
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
<properties>
<property name="hibernate.ogm.datastore.provider" value="neo4j_http"/>
<property name="hibernate.ogm.datastore.host" value="10.31.32.43"/>
<property name="hibernate.ogm.datastore.username" value="neo4j"/>
<property name="hibernate.ogm.datastore.password" value="admin123"/>
<property name="hibernate.transaction.jta.platform" value="JBossTS"/>
</properties>
</persistence-unit>
</persistence>
and I have the following code:
Code:
TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
//build the EntityManagerFactory as you would build in in Hibernate Core
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "ogm-jpa-tutorial" );
//Persist entities the way you are used to in plain JPA
try {
tm.begin();
logger.infof( "About to store dog and breed" );
EntityManager em = emf.createEntityManager();
Breed collie = new Breed();
collie.setName( "Collie" );
em.persist( collie );
Dog dina = new Dog();
dina.setName( "Dina" );
dina.setBreed( collie );
em.persist( dina );
Long dinaId = dina.getId();
em.flush();
em.close();
tm.commit();
//Retrieve your entities the way you are used to in plain JPA
logger.infof( "About to retrieve dog and breed" );
tm.begin();
em = emf.createEntityManager();
dina = em.find( Dog.class, dinaId );
System.out.println(String.format("Found dog %s of breed %s", dina.getName(), dina.getBreed().getName()) );
em.flush();
em.close();
tm.commit();
emf.close();
}
catch ( Exception e ) {
e.printStackTrace();
}
Any help will be appreciated.