It is not very likely that you are going to have to retrieve a document given its identifier and it is more likely that you get it as result of a query (apply a view) but that is going to be explained in a different post since there are many considerations to keep in mind.
In this post we are going to assume that we get the identifier of the document that we want to retrieve and and we want to retrieve a BaseDocument including the different properties. This is pretty simple using Database method getDocument :
System.out.printf("Id: %s\n", id); BaseDocument site3 = db.getDocument(BaseDocument.class, id); System.out.printf("Id: %s Revision: %s\n", site3.getId(), site3.getRevision());
and you get something like:
Id: 26d440759008bab5206a06d62d001625 Id: 26d440759008bab5206a06d62d001625 Revision: 1-005e364c46dece62177afcf3e7039dd9
The first argument of getDocument is the Java class corresponding to the stored object; the second is the identifier of the object. The result is an Object of the class that you have explecitely referenced that should inherits from Document (as BaseDocument).
In the following post I will show you how to define your own Document class and use it for storing and retrieving document.