PreviousNext…

DocumentCollection: warning!

Uh oh. I wonder if this is a bug in the Domino Java classes. Here’s one for you to try. This morning, Stefan Kassal posted a query on the Lotus Developer Domain entitled “Max parameter in db.search() in java does strange things…”. I was intrigued and set out to test his claim. Sure enough, an object implementing the DocumentCollection interface behaves in an unexpected way, with potentially catastrophic results. This is in both releases 5.x and 6.5.

Here’s how to try this out. Create some dummy documents using the same form for all, noting how many documents you create. You should then knock up an agent to get a DocumentCollection handle on just some of these documents. See what happens when you call the removeAll(true) method:

	Session session = getSession();
	AgentContext ac = session.getAgentContext();
	Database db = ac.getCurrentDatabase();
	String formula = "Form=\"YOUR_FORM_NAME\"";
	// Number to include in collection must be less
	// than total # of docs in db using form
	DocumentCollection dc = db.search(formula, null, 10);

	// Works as expected:
	int count = dc.getCount();
	System.out.println("Doc count is " + count);
	// Doesn't work as expected:
	dc.removeAll(true);

Eeek! Can’t be right, surely?

Comments

  1. I just tried it with a LotusScript agent as well, with the same result. It looks like it must be an issue with the API itself rather than Java specific. I also tried it with Java, with the same result. My client version is 6.02CF1.Marcin#
  2. Lumme, I hadn’t got around to testing with LS… crazy. Can’t believe this issue has been out there for so long!Ben Poole#

Comments on this post are now closed.

About

I’m a software architect / developer / general IT wrangler specialising in web, mobile web and middleware using things like node.js, Java, C#, PHP, HTML5 and more.

Best described as a simpleton, but kindly. You can read more here.

";