Hi, I have a hashmap inserted as global variable and some objects as facts. In drools i try to locate object from hashmap using facts. It behaves differently and i dont know why. I will post my code and then try to describe the behaviour
global java.util.Map encapsulationMap; rule "test rule" no-loop when EncapsulatingObject($key : id == 7) EncapsulatingObject( encapsulationMap[$key+""] !=null) //eval( encapsulationMap.get($key+"") != null) working then System.out.println("key is "+$key +" value is ::: "+encapsulationMap.get($key+"")); end Out put key is 7 value is ::: Encapsulating object key 7 key is 7 value is ::: Encapsulating object key 7 key is 7 value is ::: Encapsulating object key 7 key is 7 value is ::: Encapsulating object key 7 key is 7 value is ::: Encapsulating object key 7 key is 7 value is ::: Encapsulating object key 7 key is 7 value is ::: Encapsulating object key 7 key is 7 value is ::: Encapsulating object key 7 key is 7 value is ::: Encapsulating object key 7 Explanation : I have objects of Encapsulating as facts. same type of objects are present in hashmap. Field id is getting used for hashcode and for equals to store it in hashmap. I am inserting 9 facts and all of them are unique. Number of occurance if you see are 9. 1. I dont know why it behaves like this? i think there should have been just 1 object. 2. If I *comment out EncapsulatingObject( encapsulationMap[$key+""] !=null)* and *uncomment eval* i get proper results i.e only one output. BZut i want to assign object to a variable hence i have to use *EncapsulatingObject( encapsulationMap[$key+""] !=null)* Can any one explain me this behaviour ? What am i missing or where am i going wrong. Please help Thanks and Regards Avin -- View this message in context: http://drools.46999.n3.nabble.com/irrational-behaviour-by-drools-engine-tp4028104.html Sent from the Drools: User forum mailing list archive at Nabble.com. _______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users