[rules-users] Pointer to working memory from within rule?
Scott Burrows
scottjburrows at gmail.com
Fri Mar 26 13:10:11 EDT 2010
I'm converting from 4.0.7 to 5.0.1 and am getting errors on the previously
working function below, (note this function is in the drl file):
The error is:
"Type mismacth: cannot convert from org.drools.QueryResults to
org.drools.runtime.rule.QueryResults"
I'm told we need to use the following class for queries in 5.0 and going
forward:
import org.drools.runtime.rule.QueryResults;
import org.drools.runtime.rule.QueryResultsRow;
The problem is getting a pointer to working memory from within a rule or
function used to be done via the KnowledgerHelper object but that is not
compatible with the new QueryResults class.
What am I doing wrong?
-------------------------------------------------------------------------------------------------------------------------------
function CardTransaction getCompletedTransaction (String cardnum,
KnowledgeHelper khObj) {
CardTransaction tranObj = null;
String[] queryParams = {cardnum};
QueryResult result = null;
final QueryResults results =
khObj.getWorkingMemory().getQueryResults("GetCompletedTransaction",
queryParams);
for (Iterator<QueryResult> it = results.iterator(); it.hasNext(); ) {
result = it.next();
tranObj = (CardTransaction)result.get("cardtransactionobj");
}
if (tranObj != null)
return tranObj;
else
return null;
}
Scott
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100326/99a77cee/attachment.html
More information about the rules-users
mailing list