[rules-users] StatefulKnowledgeSession, serialization and FactHandle question

Laird Nelson ljnelson at gmail.com
Mon Mar 28 13:12:28 EDT 2011


Hello; I'm using Drools 5.2.0-SNAPSHOT.

I have a StatefulKnowledgeSession spawned from a KnowledgeBase whose
KnowledgeBaseConfiguration is set up to use equality, not identity for (as I
understand it) testing to see whether a fact is in the base or not.

I have this verified with a (nasty) assert statement (I didn't see any other
way to get the KnowledgeBaseConfiguration out, which looks like an API
omission to me):

assert ((InternalRuleBase)((
KnowledgeBaseImpl)sks.getKnowledgeBase()).getRuleBase()).getConfiguration().getAssertBehaviour().equals(AssertBehaviour.EQUALITY);

OK, so the internal knowledge base is using equality.

I stick some facts in via insert.  Then I serialize the session using all
the right classes from org.drools.marshalling.  I choose the full
serialization mode.

As I understand it, this means that the knowledge base and the facts will
all be serialized.  I am aware of the fact that all facts will get new
identities.

At some point in the future, I deserialize the session (successfully).

When I take the same object that I inserted, and call
statefulSession.getFactHandle(myObject), I get null back.

This is despite the fact that my object has an equals() method, and that the
equals() method is heavily unit tested (and simple).

That is, despite the fact that the KnowledgeBase is confirmed to use
equality, not identity, there does not seem to be a way to test if the
session contains a particular fact.  It's like identity is still being used.

Am I overlooking something obvious?

Thanks,
Laird
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110328/a3ab31be/attachment.html 


More information about the rules-users mailing list