a135
a135

Reputation: 119

Failing to retrieve records from database via Java

I am trying to get the rows in a Lotus-Domino nsf database via Java. I did manage to successfully get the column names and column count, for they are the same as shown on my ibm notes client. However, whenever I get ViewEntryCollection via view.getAllEntries(), it seems to be empty.

I have tried several different options, including reflection.

for (Object object : database.getViews()) {
    View view = (View) object;
    if (view.getName().equals("For Printing\\By Date")) {

        // this prints out "view.getEntryCount() = 1145"
        System.out.println("view.getEntryCount() = " + view.getEntryCount());

        // this prints out "view.getAllEntries().getFirstEntry() = null"
        System.out.println("view.getAllEntries().getFirstEntry() = " + 
                        view.getAllEntries().getFirstEntry());

        break;
    }
}

I expect the first entry to be defined, because it says it's entry count is 1145, but it's null instead. Is this a permission issue?

Upvotes: 0

Views: 105

Answers (2)

Richard Schwartz
Richard Schwartz

Reputation: 14628

Yes, this can be a permissions issue, and it very likely is. The getEntryCount does not check your access to the underlying entries. It simply returns the number of entries that the indexer counted.

But if the identity that the code runs under (your user id, or the code signer if it is an agent) does not have read permission for any documents in the view (due to the use of ReaderName fields in the document, most likely) then getFirstEntry() will return null. You need to make sure that the code runs under the identity of a user who has the appropriate level of access.

Upvotes: 3

kayesh parvez
kayesh parvez

Reputation: 353

I think there is nothing wrong in the output. view.getEntryCount() is giving actual count, where view.getAllEntries().getFirstEntry()is saying that the first entry is null. That doesn't mean that there is no entry there, rather it says that the object reference in the first entry is pointing to null.

Upvotes: 1

Related Questions