Isaac
Isaac

Reputation: 16736

View.getEntryCount() returns 1500, but can't get any document by key?

I'm writing a simple standalone Java class that uses Lotus Domino's NCSO JAR for remote-connecting to a Domino server.

I'm establishing a session, getting access to a database and then to a view:

Session session = NotesFactory.createSession("host", "user", "password");
Database db = session.getDatabase(null, "MyDB.nsf");
View view = db.getView("MyView");

Now, I'm printing the number of entries in the view:

int count = view.getEntryCount();

I get a nonzero number (let's say 1500).

However, I can't seem to load any document by key. For example, for any letter in the alphabet, I'm getting an empty document collection with this call:

System.err.println(view.getAllDocumentsByKey(letter, false));

When I try to load a document by key, when I know that the key exists in the view, I get null.

Document document = view.getDocumentByKey("DocKey"); // Equals null even though
                                                     // I know that 'DocKey' is
                                                     // the key of an existing
                                                     // document within the view.

The very same code is said to be working (although I didn't check it) when using local Notes calls (using Notes.jar).

What am I missing?

EDIT

I just noticed that session.getNotesVersion() returns version 8.5.2. The NCSO.jar file that I'm currently using doesn't appear to have a few methods that were added with Notes 8. Therefore, there is a possibility that the NCSO.jar file I use belongs to an earlier version of Notes than the one I'm trying to communicate with. Could that be the reason?

Upvotes: 1

Views: 353

Answers (2)

Karl-Henry Martinsson
Karl-Henry Martinsson

Reputation: 2795

Assuming I understand you right, you want to get all documents where the first (lookup) column of the view contains anything that starts with a specific letter? E.g. you send "A" to veiw.getAllDocumentsByKey() and expect a collection that contains "Apple", "Alpha", "Amoeba" and "Apricot" to be returned?

I would modify the column in the view to only hold the first letter: @Left(MyField;1) Then it would be easy to perform the lookup and see if you get the correct result.

Upvotes: 0

Richard Schwartz
Richard Schwartz

Reputation: 14628

If the same code is working locally, then that should rule out the possibility that the first column of the view isn't sorted. Assuming that, then the most likely issue is that the documents are protected by ReaderNames fields and the identity that you are using for authenticating your session does not have access to the documents.

Upvotes: 2

Related Questions