OpenNTF/org.openntf.domino

Document returns wrong parent database after performing a copyToDatabase()

markleusink opened this issue · 1 comments

It appears that the parentDatabase reference isn't updated after copying a document using copyToDatabase(). The code below outputs the same replica ID for both the source and target parent databases.

If you run the same code using the lotus.domino objects, it returns the corrent (different) replica id's.

String dbPath = "some-db-not-current.nsf";

Database dbSrc = XSPUtil.getCurrentSession().getDatabase("", dbPath);
Document docSrc = dbSrc.getAllDocuments().getFirstDocument();

Database dbCurrent = XSPUtil.getCurrentDatabase();
Document docCopied = docSrc.copyToDatabase(dbCurrent);

System.out.println("source doc in: " + docSrc.getParentDatabase().getReplicaID() );
System.out.println("target doc in: " + docCopied.getParentDatabase().getReplicaID() );

I believe copyToDatabase() is less performant that .createDocument() and .copyAllItems(). As a workaround, I'd recommend using the latter format and, unless anyone knows to the contrary, I suggest we change the code to do this anyway.