Hi,

   Please note that java.lang.Integer is an immutable class. So, what is happening when you do:

unEntier++;
update(unEntier);

   is that java is actually doing is creating another, different java.lang.Integer object (using auto-boxing/unboxing).
   What you need to do is:

rule "incrementation"
        no-loop
        when
                unEntier : java.lang.Integer()
        then
                retract( unEntier );
                unEntier++;
                System.out.println("incrementation firing...");
                insert(unEntier);
end


    []s
    Edson

2007/8/2, hypnosat7 <ablarbi@yahoo.fr>:

hi I have an exception after using an update

  This is my rule :

package packageDrlTest

#list any import classes here.
import java.lang.Integer;


#declare any global variables here

rule "incrementation"
        no-loop
        when
                unEntier : java.lang.Integer()
        then
                unEntier++;
                System.out.println("incrementation firing...");
                update(unEntier);

end


when I execute my rule on this list of facts :

List integerList = new ArrayList();
integerList.add(Integer.valueOf(1));
for (Object fact : integerList )
{
        session.insert(fact);  // session is a StatefulMemory
}

Update error: handle not found for object: 2. Is it in the working memory?

détails :

incrementation firing...
org.drools.FactException : Update error: handle not found for object: 2. Is
it in the working memory?
        at
org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:93)
        at
packageDrlTest.Rule_incrementation_0.consequence (Rule_incrementation_0.java:9)
        at
packageDrlTest.Rule_incrementation_0ConsequenceInvoker.evaluate(Rule_incrementation_0ConsequenceInvoker.java:22)
        at org.drools.common.DefaultAgenda.fireActivation (DefaultAgenda.java:545)
        at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:509)
        at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:430)
        at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:392)
--
View this message in context: http://www.nabble.com/Update-error%3A-handle-not-found-for-object-tf4206369.html#a11965297
Sent from the drools - user mailing list archive at Nabble.com.


_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



--
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com