[rules-users] QueryResult.getFactHandles bug?

Fenderbosch, Eric Eric.Fenderbosch at fedex.com
Mon Jun 9 11:38:49 EDT 2008


I didn't find a JIRA for this and I'm pretty sure my test is valid.

QueryResult.getFactHandles() seems to be only returning [fid:-1:X:null]

I'm using 4.0.7.

Here's my test case:
public void testQueryResults() throws Exception {
	StatefulSession workingMemory = DroolsUtil.getWorkingMemory();
	TestFact testFact = new TestFact();
	String id = "1234";
	testFact.setId(id);
	FactHandle testHandle = workingMemory.insert(testFact);
	System.out.println(testHandle);

	Object[] args = {id};
	int resultCount = 0;
	int factCount = 0;
	int handleCount = 0;
	Object fact = null;
	FactHandle handle = null;

	// query getTestFact(String _id)
	//	TestFact(id == _id)
	// end
	QueryResults queryResults =
workingMemory.getQueryResults("getTestFact", args);
	Iterator<QueryResult> iterator = queryResults.iterator();
	while (iterator.hasNext()) {
		resultCount++;
		QueryResult result = iterator.next();
		FactHandle[] handles = result.getFactHandles();
		for (FactHandle h : handles) {
			handleCount++;
			handle = h;
		}
		for (int i = 0; i < result.size(); i++) {
			factCount++;
			fact = result.get(i);
		}
	}
	System.out.println(handle);
	assertTrue(resultCount == 1);
	assertTrue(factCount == 1);
	assertTrue(testFact == fact);
	assertTrue(handleCount == 1);
	// this fails
	assertTrue(testHandle == handle);
}

TestFact is very simple, using id in hashCode and equals.

Am I using getFactHandles correctly?

Thanks.




More information about the rules-users mailing list