Search in sources :

Example 1 with Item

use of org.neo4j.ogm.domain.linkedlist.Item in project neo4j-ogm by neo4j.

the class BidirectionalMappingTest method shouldHandleSelfReferencingObjectOnRollback.

@Test
public void shouldHandleSelfReferencingObjectOnRollback() {
    Item item = new Item();
    item.next = item;
    item.previous = item;
    try (Transaction tx = session.beginTransaction()) {
        session.save(item);
        session.deleteAll(Item.class);
    }
}
Also used : Item(org.neo4j.ogm.domain.linkedlist.Item) Transaction(org.neo4j.ogm.transaction.Transaction) Test(org.junit.Test)

Example 2 with Item

use of org.neo4j.ogm.domain.linkedlist.Item in project neo4j-ogm by neo4j.

the class BidirectionalMappingTest method shouldLoadDoublyLinkedList.

/**
 * @see DATAGRAPH-636
 */
@Test
public void shouldLoadDoublyLinkedList() {
    Item first = new Item();
    Item second = new Item();
    Item third = new Item();
    first.next = second;
    second.next = third;
    session.save(first);
    session.clear();
    first = session.load(Item.class, first.getId(), -1);
    assertThat(first.next.getId()).isEqualTo(second.getId());
    assertThat(first.next.next.getId()).isEqualTo(third.getId());
    assertThat(first.next.next.next).isNull();
    assertThat(first.previous).isNull();
    assertThat(first.next.previous.getId()).isEqualTo(first.getId());
    assertThat(first.next.next.previous.getId()).isEqualTo(second.getId());
}
Also used : Item(org.neo4j.ogm.domain.linkedlist.Item) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Item (org.neo4j.ogm.domain.linkedlist.Item)2 Transaction (org.neo4j.ogm.transaction.Transaction)1