diff --git a/pom.xml b/pom.xml index b989387d64f0d5e597049f59d1e008200a67f324..f3adfb95d967eb87cf009d914bfc215d606a8354 100644 --- a/pom.xml +++ b/pom.xml @@ -87,5 +87,16 @@ <version>1.2.17</version> <scope>runtime</scope> </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.7.7</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>com.wingnest.blueprints</groupId> + <artifactId>blueprints-jpa-graph</artifactId> + <version>2.5.0_01</version> + </dependency> </dependencies> </project> diff --git a/src/test/java/com/syncleus/grail/graph/hibernate/DogBreedTest.java b/src/test/java/com/syncleus/grail/graph/hibernate/DogBreedTest.java index 2a2c4f91f58ef4b866869182f2dc79d3927fcd6a..f9dfe76e1827831339a31db52471181930640f0a 100644 --- a/src/test/java/com/syncleus/grail/graph/hibernate/DogBreedTest.java +++ b/src/test/java/com/syncleus/grail/graph/hibernate/DogBreedTest.java @@ -2,6 +2,7 @@ package com.syncleus.grail.graph.hibernate; import com.syncleus.grail.graph.hibernate.domain.Breed; import com.syncleus.grail.graph.hibernate.domain.Dog; +import com.tinkerpop.blueprints.Vertex; import junit.framework.Assert; import org.hibernate.ogm.util.impl.Log; import org.hibernate.ogm.util.impl.LoggerFactory; @@ -11,6 +12,7 @@ import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.Persistence; +import com.wingnest.blueprints.impls.jpa.*; public class DogBreedTest { @@ -50,4 +52,34 @@ public class DogBreedTest { emf.close(); } + + @Test + public void testJpa() { + //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 + EntityManager em = emf.createEntityManager(); + EntityTransaction tm = em.getTransaction(); + tm.begin(); + 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(); + + final JpaGraph graph = new JpaGraph(emf); + graph.begin(); + final Vertex dinaVertex = graph.getVertex(dinaId); + Assert.assertEquals("Dina", dinaVertex.getProperty("name")); + graph.commit(); + + emf.close(); + } }