[rules-users] Comparing KnowledgePackages for Equality

gqmulligan gqmulligan at gmail.com
Thu Mar 21 16:34:41 EDT 2013


I am using Drools 5.3.1.Final in case that is useful information.

Thanks Esteban for the suggestion but I could not get that to work.  I must
be doing something wrong.  Here is what I am trying to do in a nutshell.

I read in several standard rules and guided rules, add them all to a
KnowledgeBuilder,  and then get the resulting KnowledgePackage from the
KnowledgeBuilder.  I then save this KnowledgePackage to a database using
Hibernate.  My problem is now every time I read the package from the
database Hibernate thinks the object is dirty and updates the rule package.

A byte comparison of two packages does not work because you are not
guaranteed everything in the package will be serialized in the same order,
as I found.  To test this I deserialized two packages from the same byte
stream, serialized them, and all resulting byte arrays were different.

When I tried Esteban's idea I read the KnowledgePackage from the database
but all the rules in the package do not have a consequence until I add the
package to a KnowledgeBase.  This means that I cannot use a
BinaryResourceDiffProducerImpl because that compares rule consequences and
throws a NullPointerException in my case.

Any other ideas on how I can successfully compare two KnowledgePackages that
represent the same set of rules or even another suggestion altogether to get
KnowledgePackages to play nicely with Hibernate?



--
View this message in context: http://drools.46999.n3.nabble.com/Comparing-KnowledgePackages-for-Equality-tp4022952p4022979.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list