Thanks for the replies. I'm just pointing out a
difference in behavior. What Edson said explained why.
Given that explanation though, I'm afraid this example
rule from the wiki is no longer what it is meant to
demonstrate:
rule "Hello World"
when
m : Message(list contains "hello")
Message(message == "hola")
Message(number > 40)
Message(birthday > "10-Jul-1974")
Message(message matches ".*ho.*")
then
System.out.println("hello world " +
m.getMessage());
m.setFired(true);
end
If I understand it correctly, for this rule to fire,
five Message objects need to be inserted.
I agree with Michael that eval can be used as a
workaround.
Yuesong
--- Michael Neale <[EMAIL PROTECTED]> wrote:
> OK I thought this may cause an issue.
>
> As Yuesong said, it was handy to be able to spread
> conditions across lines
> (sentences in DSLs) as it made it more readable. Now
> when we do that, it
> won't work.
> So what do we do? Allow the identity cross product?
> In simple cases, yes it does make things easier, but
> I think in practice,
> the benefit of removing the cross product will save
> people a lot of hassle.
>
> The case Yuesong mentions is valid though, as in you
> may want to just keep
> adding "stand alone" constraints to a fact. But in
> that case, (with RC1) if
> you added one more Message to working memory, then
> suddenly you would see
> "wierd" behaviour (as you are getting all possible
> matches). Hence I think
> that removing the cross products is probably the
> most desirable behaviour.
> And also, it is possible to do what is required by
> Yuesong via a work around
> with "eval" adding more constraints - its not
> optimal (it is a work around)
> but in simple cases it may be fine.
> As always if we get enough pressure, we can make
> this configurable
> behaviour. But from Drools 2.x experience, we get a
> LOT of confusion over
> the cross product stuff, and this saves a lot of
> hassle.
>
>
> On 4/18/06, Edson Tirelli
> <[EMAIL PROTECTED]> wrote:
> >
> > Actually, there is one thing that changed and
> might affect this use
> > case:
> > it is the filter on identity cross product.
> >
> > Before RC2, if you had a Rule with 2 columns of
> the same type, like the
> > rule you wrote bellow, every object in the working
> memory of that type,
> > would try to match against itself. So, for
> instance, if you had asserted
> > two
> > messages (m1 and m2) in the working memory for
> this rule, the activations
> > would be:
> >
> > [m1, m1]
> > [m1, m2]
> > [m2, m1]
> > [m2, m2]
> >
> > In RC2, we added an identity removal constraint
> to not allow identity
> > activations like [m1, m1] and [m2, m2].
> >
> > So, what is probably happening to you is that
> you are asserting a
> > single
> > message object in the working memory. Before RC2,
> it would create an
> > activation for [m1, m1] and now it does not
> creates anymore.
> > As Mark said, this is probably and error when
> writing the rule, as the
> > rule should have only one column, not two. A
> better way to write this rule
> > would be:
> >
> > rule "Hello World"
> > when
> > m : Message( status == Message.HELLO,
> message == "Hello World" )
> > then
> > System.out.println( "fired" );
> > end
> >
> > This way, each single message object asserted
> into working memory that
> > matches the constraints, will cause an activation.
> >
> > []s
> > Edson
> >
> >
> > ----- Original Message -----
> > From: "Mark Proctor" <[EMAIL PROTECTED]>
> > To: <[email protected]>
> > Sent: Monday, April 17, 2006 4:26 PM
> > Subject: Re: [drools-user] RC2
> >
> >
> > > package com.sample
> > > import com.sample.DroolsTest.Message;
> > > rule "Hello World"
> > > when
> > > m : Message( status == Message.HELLO )
> > > Message( message == "Hello World" )
> > > then
> > > System.out.println( "fired" );
> > > end
> > >
> > > That's filtering on two columns, its like doing
> this in SQL:
> > > select * from Message, Message
> > > Not what most people want. This hasn't changed
> in any of the releases
> > > in Drools 3.0
> > >
> > > Mark
> > >
> > > Yuesong Wang wrote:
> > > > Thanks for the great job on RC2. Solved a lot
> of my
> > > > problem :)
> > > >
> > > > The following rule, however, does not work in
> RC2
> > > > anymore...
> > > >
> > > > package com.sample
> > > > import com.sample.DroolsTest.Message;
> > > > rule "Hello World"
> > > > when
> > > > m : Message( status == Message.HELLO )
> > > > Message( message == "Hello World" )
> > > > then
> > > > System.out.println( "fired" );
> > > > end
> > > >
> > > > So the field constraints have to be in the
> sample
> > > > column? like
> > > >
> > > > m:Message(status==0, message=="Hello World")
> > > >
> > > > That is probably no good, especially for
> someone who
> > > > wants to use DSL and map individul conditions
> to
> > > > separate sentences.
> > > >
> > > > Yuesong
> > > >
> > > >
> __________________________________________________
> > > > Do You Yahoo!?
> > > > Tired of spam? Yahoo! Mail has the best spam
> protection around
> > > > http://mail.yahoo.com
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >
> > > --
> > > No virus found in this incoming message.
> > > Checked by AVG Free Edition.
> > > Version: 7.1.385 / Virus Database: 268.4.2/314 -
> Release Date: 16/4/2006
> > >
> > >
> >
> >
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com