hmmm... have you tried setting "dialect 'mvel' " for the rule/package? <div><br class="webkit-block-placeholder"></div><div>I am not sure if you can do that even in java 5 (but in MVEL we can make it happen if it doesn't already).<br>
<br><div class="gmail_quote">On Jan 25, 2008 11:19 PM, José Arrarte <<a href="mailto:jarrarte@gmail.com">jarrarte@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;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">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 href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a 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>Michael D Neale<br>home: <a href="http://www.michaelneale.net">www.michaelneale.net</a><br>blog: <a href="http://michaelneale.blogspot.com">michaelneale.blogspot.com</a>
</div>