It is just a test case used to bring up the issue. The real rule condition in my business logic is more complex, like <br>Order( id == '...', $msg.date > '...', num == $msg.num ). Of course I can change to use Message as Pattern to work aournd, but it is too tricky, right? And no matter the usage is weird or not, it is legal, right? <br>
<br>I am using Drools 4.0.7. If later release fixes this bug, I may try to upgrade. I don't want to change LHS. It will bring much effort in my project.<br><br><br><div class="gmail_quote">On 30 March 2012 14:09, FrankVhh <span dir="ltr"><<a href="mailto:frank.vanhoenshoven@agserv.eu" target="_blank">frank.vanhoenshoven@agserv.eu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Let me rephrase my question:<br>
<br>
As date is an attribute of message, why don't you use:<br>
<br>
$msg : Message( date > "...")<br>
<br>
Constraining an attribute of Message in the Order pattern seems a weird<br>
thing to do.<br>
<br>
<br>
<br>
Zeke-3 wrote<br>
<div>><br>
> It seems not work.<br>
> When I try<br>
</div><div>> *$msg : Message($date : date)<br>
> Order ( $date > "Mar-01-2012" )*<br>
</div><div>> I meet error "Unable to create Field Extractor for '$date' of<br>
> '[ClassObjectType class=org.drools.examples.HelloWorldExample$Second]' in<br>
> rule 'default' : [Rule name=default, agendaGroup=MAIN, salience=0,<br>
> no-loop=false]"<br>
><br>
> When I try<br>
</div>> *$msg : Message($date : date)<br>
> eval ( $date > "Mar-01-2012" )*<br>
<div>> If the dialect is "java", I meet error "Rule Compilation error : [Rule<br>
> name=default, agendaGroup=MAIN, salience=0, no-loop=false]<br>
> org/drools/examples/test/Rule_default_0.java (8:354) : The operator ><br>
> is undefined for the argument type(s) Date, String"<br>
> If the dialect is "mvel", I meet the same ClassCastException.<br>
><br>
</div><div><div>> On 29 March 2012 22:28, FrankVhh &lt;frank.vanhoenshoven@&gt; wrote:<br>
><br>
>> This may sound a bit rude, but... why would you want to do such a thing?<br>
>><br>
>> If there is a constraint on the message, then why not put that constraint<br>
>> in<br>
>> the message structure?<br>
>><br>
>> Btw, I think it would work by using eval($date < "...") but see no use<br>
>> for<br>
>> it either.<br>
>><br>
>><br>
>> Joe Zendle wrote<br>
>> ><br>
>> > did you try:<br>
>> ><br>
>> > *$msg : Message($date : date)<br>
>> > Order ( $date > "Mar-01-2012" )*<br>
>> ><br>
>> ><br>
>> ><br>
>> > 2012/3/29 Zeke &lt;xanadu860122@&gt;<br>
>> ><br>
>> >> Hi, guys:<br>
>> >> I meet a strange issue and need your help again... I am using Drools<br>
>> >> 4.0.7.<br>
>> >> When my rule condition is as *Message( date > "Mar-01-2012" )*,<br>
>> >> everything is OK. But if I change it to be as below:<br>
>> >> *$msg : Message()<br>
>> >> Order ( $msg.date > "Mar-01-2012" )*<br>
>> >> I will meet "java.lang.String cannot be cast to java.util.Date"<br>
>> >> ClassCastException. "Order" is another fact. I attach the exception<br>
>> call<br>
>> >> stack. Please check it. It looks like a bug to me. Do we fix it in<br>
>> later<br>
>> >> release? If so, can you tell me which release contains the fix?<br>
>> Thanks!<br>
>> >><br>
>> >> _______________________________________________<br>
>> >> rules-users mailing list<br>
>> >> rules-users@.jboss<br>
>> >> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>> >><br>
>> >><br>
>> ><br>
>> > _______________________________________________<br>
>> > rules-users mailing list<br>
>> > rules-users@.jboss<br>
>> > <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>> ><br>
>><br>
>><br>
>> --<br>
>> View this message in context:<br>
>> <a href="http://drools.46999.n3.nabble.com/rules-users-ClassCastException-when-comparing-date-type-with-literal-tp3867229p3867832.html" target="_blank">http://drools.46999.n3.nabble.com/rules-users-ClassCastException-when-comparing-date-type-with-literal-tp3867229p3867832.html</a><br>
>> Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
>> _______________________________________________<br>
>> rules-users mailing list<br>
>> rules-users@.jboss<br>
>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>><br>
><br>
> _______________________________________________<br>
> rules-users mailing list<br>
> rules-users@.jboss<br>
> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
><br>
<br>
<br>
--<br>
</div></div>View this message in context: <a href="http://drools.46999.n3.nabble.com/rules-users-ClassCastException-when-comparing-date-type-with-literal-tp3867229p3870029.html" target="_blank">http://drools.46999.n3.nabble.com/rules-users-ClassCastException-when-comparing-date-type-with-literal-tp3867229p3870029.html</a><br>
<div><div>Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
</div></div></blockquote></div><br>