Search in sources :

Example 1 with BaseEntity

use of org.neo4j.ogm.domain.hierarchy.relations.BaseEntity in project neo4j-ogm by neo4j.

the class HierarchyRelsTest method saveMultipleRelationshipsToBase.

// GH-152
@Test
public void saveMultipleRelationshipsToBase() {
    Type1 node1 = new Type1();
    node1.name = "type1";
    Type2 node2 = new Type2();
    node2.name = "type2";
    node1.addIncoming(node2);
    node2.addIncoming(node1);
    Transaction transaction = session.beginTransaction();
    session.save(node1);
    transaction.commit();
    transaction.close();
    session.clear();
    transaction = session.beginTransaction();
    BaseEntity entity = session.load(BaseEntity.class, node1.getGraphId());
    transaction.close();
    assertThat(entity.getIncoming()).hasSize(1);
    assertThat(entity.getOutgoing()).hasSize(1);
    assertThat(node2.getGraphId()).isEqualTo(entity.getIncoming().get(0).getGraphId());
    assertThat(node2.getGraphId()).isEqualTo(entity.getOutgoing().get(0).getGraphId());
}
Also used : Type2(org.neo4j.ogm.domain.hierarchy.relations.Type2) Transaction(org.neo4j.ogm.transaction.Transaction) BaseEntity(org.neo4j.ogm.domain.hierarchy.relations.BaseEntity) Type1(org.neo4j.ogm.domain.hierarchy.relations.Type1) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 BaseEntity (org.neo4j.ogm.domain.hierarchy.relations.BaseEntity)1 Type1 (org.neo4j.ogm.domain.hierarchy.relations.Type1)1 Type2 (org.neo4j.ogm.domain.hierarchy.relations.Type2)1 Transaction (org.neo4j.ogm.transaction.Transaction)1