[rules-users] Updating a Boolean object in the WM

Wolfgang Laun wolfgang.laun at gmail.com
Thu Jul 16 05:56:23 EDT 2009


Well, you can't change a Java object Boolean b; assigning another Boolean to b
changes the object reference stored in b. Boolean has no setters.

Notice that the CE
    when
            Boolean()

always is true irrespective of the Boolean object that's in the WM.

If writing a Java fact class strains you too much, check the Expert
documentation
for "declare", to define a suitable fact type in your drl file.

For good obfuscation, you might try java.util.BitSet, (ab)using isEmpty().
   BitSet( empty == true )

-W


On Thu, Jul 16, 2009 at 11:31 AM, skasab2s<skasab2s at smail.inf.fh-brs.de> wrote:
>
> Hi guys,
>
> I've been desperately trying to update a Boolean object, which is in the
> working memory.
>
> I have an initial rule that  first inserts it:
> rule "Insert initial weanable value" salience 100
>        when
>
>        then
>                Boolean $weanable = false;
>                insert($weanable);
> end
>
> and then I try to update it:
>       ...
>       when
>               $weanable: Boolean( )
>               ...
>       then
>                $weanable=true;
>                update($weanable);
> end
>
> Which results to this exception : org.drools.FactException: Update error:
> handle not found for object: true. Is it in the working memory?
> I checked in the working memory and the Boolean-object was there!
>
>
> Is it possible to update a boolean that is in the working memory? If not, do
> you know some other Java class with setters and getters (behaving as a
> drools-fact) that I don't have to create myself and which I can use instead
> of Bboolean for this case ?
>
> Thanks in advance!
>
> Svetlomir
>
> --
> View this message in context: http://www.nabble.com/Updating-a-Boolean-object-in-the-WM-tp24513225p24513225.html
> Sent from the drools - user mailing list archive at Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> http://lists.jboss.org/mailman/listinfo/rules-users
>




More information about the rules-users mailing list