@@ -0,0 +1,1702 @@
+package com.orientechnologies.orient.core.db.document;%0A%0Aimport com.orientechnologies.orient.core.record.impl.ODocument;%0Aimport org.testng.annotations.AfterMethod;%0Aimport org.testng.annotations.BeforeMethod;%0Aimport org.testng.annotations.Test;%0A%0Aimport static org.testng.Assert.assertEquals;%0A%0A/**%0A * Created by tglman on 26/10/15.%0A */%0Apublic class TestRecursiveLinkedSave %7B%0A%0A  private ODatabaseDocument db;%0A%0A  @BeforeMethod%0A  public void before() %7B%0A    db = new ODatabaseDocumentTx(%22memory:%22 + TestRecursiveLinkedSave.class.getSimpleName());%0A    db.create();%0A  %7D%0A%0A  @Test%0A  public void testLinked() %7B%0A    db.getMetadata().getSchema().createClass(%22Test%22);%0A    ODocument doc = new ODocument(%22Test%22);%0A    ODocument doc1 = new ODocument(%22Test%22);%0A    doc.field(%22link%22, doc1);%0A    ODocument doc2 = new ODocument(%22Test%22);%0A    doc1.field(%22link%22, doc2);%0A    doc2.field(%22link%22, doc);%0A    doc = db.save(doc);%0A    assertEquals(3, db.countClass(%22Test%22));%0A    doc = db.load(doc.getIdentity());%0A    doc1 = doc.field(%22link%22);%0A    doc2 = doc1.field(%22link%22);%0A    assertEquals(doc, doc2.field(%22link%22));%0A  %7D%0A%0A  @Test%0A  public void testTxLinked() %7B%0A    db.getMetadata().getSchema().createClass(%22Test%22);%0A    db.begin();%0A    ODocument doc = new ODocument(%22Test%22);%0A    ODocument doc1 = new ODocument(%22Test%22);%0A    doc.field(%22link%22, doc1);%0A    ODocument doc2 = new ODocument(%22Test%22);%0A    doc1.field(%22link%22, doc2);%0A    doc2.field(%22link%22, doc);%0A    db.save(doc);%0A    db.commit();%0A    assertEquals(3, db.countClass(%22Test%22));%0A    doc = db.load(doc.getIdentity());%0A    doc1 = doc.field(%22link%22);%0A    doc2 = doc1.field(%22link%22);%0A    assertEquals(doc, doc2.field(%22link%22));%0A  %7D%0A%0A  @AfterMethod%0A  public void after() %7B%0A    db.drop();%0A  %7D%0A%0A%7D%0A

add unit test for ricursive link save in case of tx and not tx.