<br> Looks like a bug to me. May I ask you plz to open a JIRA?<br><br> []s<br> Edson<br><br><div><span class="gmail_quote">2008/1/25, José Arrarte <<a href="mailto:jarrarte@gmail.com">jarrarte@gmail.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello,<br><br>First of all, I'd like to thank all the people involved in making this tool such a great one (this includes whoever writes the reference manual as well).<br><br>I've been having some problems when comparing BigDecimals (using the compareTo method). I didn't find this issue in any previous post or in Drools' JIRA. However, I've been using Drools for a short time, so I hope you people can help me.
<br><br>The problem:<br><br>Firing this (simple) rule:
<br>
<br><span style="font-family: courier new,monospace;">
rule "Test Rule"
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> when
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $dec : java.math.BigDecimal() from java.math.BigDecimal.TEN;
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> eval( $dec.compareTo(java.math.BigDecimal.ONE) > 0 )
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> then
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> System.out.println("OK!");                
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">end
</span><br style="font-family: courier new,monospace;">
<br>Fires this exception:
<br>
<br><span style="font-family: courier new,monospace;">
org.drools.RuntimeDroolsException: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.math.BigDecimal
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:76)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        at org.drools.reteoo.EvalConditionNode.assertTuple(EvalConditionNode.java:145)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        at org.drools.reteoo.SingleTupleSinkAdapter.propagateAssertTuple(SingleTupleSinkAdapter.java:20)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        at org.drools.reteoo.FromNode.assertTuple(FromNode.java:90)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        at org.drools.reteoo.SingleTupleSinkAdapter.createAndPropagateAssertTuple(SingleTupleSinkAdapter.java:55)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        at org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:116)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:22)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:153)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        at org.drools.reteoo.Rete.assertObject(Rete.java:175)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        at org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.execute(ReteooWorkingMemory.java:179)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:1315)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:462)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:433)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        at com.sample.DroolsTest.main(DroolsTest.java:33)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.math.BigDecimal
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        at com.sample.Rule_Test_Rule_0Eval0Invoker.evaluate(Rule_Test_Rule_0Eval0Invoker.java:12)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:72)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        ... 14 more<br><br><font face="arial,sans-serif">I've reported the issue in JIRA (<a href="http://jira.jboss.com/jira/browse/JBRULES-1433" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://jira.jboss.com/jira/browse/JBRULES-1433</a>)<br>
<br>Best regards,<br>
José<br></font></span>
<br>_______________________________________________<br>rules-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>