-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Use Neo4J with JTA
PostPosted: Thu Feb 23, 2017 10:33 am 
Newbie

Joined: Thu Feb 23, 2017 10:28 am
Posts: 1
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.


Top
 Profile  
 
 Post subject: Re: Use Neo4J with JTA
PostPosted: Fri Feb 24, 2017 6:26 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
You did not mention what problem you have. Is there some error stack trace?


Top
 Profile  
 
 Post subject: Re: Use Neo4J with JTA
PostPosted: Mon Feb 27, 2017 7:56 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
Try removing this property:
Quote:
<property name="hibernate.transaction.jta.platform" value="JBossTS"/>


But please, let us know what kind of exception you see for more help.

Thanks,
Davide


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.