Drools only cares about facts, not the fields within it - when you tell Drools 
you have updated a fact object then it re-evaluates all the rules that uses the 
fact, you don't tell it which fields have actually changed. Therefore you can 
have inter-related fields without any problems.

I don't know for sure but I think that when you use update to tell drools the 
object has been updated it will update the hashcode to the new value and so 
maintain the checking of equality.

Thomas

> -----Original Message-----
> From: [email protected] [mailto:rules-users-
> [email protected]] On Behalf Of Bruno Freudensprung
> Sent: 08 December 2010 14:00
> To: Rules Users List
> Subject: [rules-users] Identity, equality, hashing and indexing
>
> Hi,
>
> I have some existential questions about Drools Expert's magic :-).
>
> When reading the documentation it is clear that, by default, facts are
> stored in an IdentityHashMap. If I understand things correctly it means
> that the objects I put in the working memory don't have to implement the
> hashCode() and equals() method. They should implement them only if I
> tell Drools to use the "equality mode".
>
> So here is my first question: in equality mode, if a fact field is used
> by the hashCode method, and if that field is modified by a rule action,
> should I expect a weird behavior since facts are stored in a HashMap?
>
> When digging into rules-users' archives I also found posts of Mark
> Proctor, talking about field indexing and alpha node hashing, that lead
> to my second question: should I expect a weird behavior if 2 fields are
> related to each other?
> For instance (not a good example but it gives an idea): a Person type
> has a getFirstName() method, a getLastName() method and a getName()
> method that return the concatenation of getFirstName() and getLastName().
> Is it problematic if one rule has a "Person(name == "John Doe")" fact in
> its LHS and if another rule modifies the "firstName" of that Person fact
> (John -> Jane)?
> Does it depend on the equality vs. identity mode (I don't think so...
> unless the field itself is a also a fact)?
>
> Many thanks in advance for your answers,
> Best regards,
>
> Bruno.
>
>
> _______________________________________________
> rules-users mailing list
> [email protected]
> https://lists.jboss.org/mailman/listinfo/rules-users


**************************************************************************************
This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the 
[email protected] and delete it from your system as well as any copies. The 
content of e-mails as well as traffic data may be monitored by NDS for 
employment and security purposes. To protect the environment please do not 
print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, 
United Kingdom. A company registered in England and Wales. Registered no. 
3080780. VAT no. GB 603 8808 40-00
**************************************************************************************

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to