<div dir="ltr"><div><div><div><div>I continue to play with the code attached to <a href="https://issues.jboss.org/browse/DROOLS-136">https://issues.jboss.org/browse/DROOLS-136</a> in src.zip. Updated invoice.drl is attached in this mail.<br>
<br></div>I changed the rule &quot;calculate totalPrice per item&quot; to MVEL and trying to calculate and set totalPrice with one liner:<br><br>((DataItemPrice)$v).setTotalPrice(((DataItemPrice)$v).getQty()*((DataItemPrice)$v).getUnitPrice());<br>
<br></div>but that fails with message: java.lang.IllegalArgumentException: object is not an instance of declaring class<br><br></div>On the other hand using temporary variable of type Double will work. Here is the complete rule which works up to the comment &quot;// THIS IS DOESN&#39;T WORK&quot;:<br>
<br>rule &quot;calculate totalPrice per item&quot;<br>salience -10<br>no-loop<br>when<br>    $q:Message(id==&quot;item&quot;, answered==true,<br>        value instanceof DataItemPrice, $v:value<br>    )<br>then<br>    System.out.println(&quot;setting totalPrice on item: &quot; + ((DataItemPrice)$v).getName());<br>
    <br>    System.out.println(&quot;qty*unitPrice=&quot; + ((DataItemPrice)$v).getQty()*((DataItemPrice)$v).getUnitPrice());<br>    <br><b>    Double d = ((DataItemPrice)$v).getQty()*((DataItemPrice)$v).getUnitPrice();<br>
    ((DataItemPrice)$v).setTotalPrice(d);<br></b>    System.out.println(&quot;setting via temporary variable worked&quot;);<br>     <br>    // THIS IS DOESN&#39;T WORK<br>    <b>((DataItemPrice)$v).setTotalPrice(((DataItemPrice)$v).getQty()*((DataItemPrice)$v).getUnitPrice());</b><br>
    System.out.println(&quot;setting directly works ???&quot;);<br><br>    update($q);<br>end<br><br></div>Am I again wrongly hoping that MVEL will simplify data types casting ? Or should I fail a bug ?<br><div><div><br><div>
<div><div><br></div></div></div></div></div></div>