Your rule doesn&#39;t make sense to me. It accumulates three Sets for cardinality tests from the same domain ($loan.garantees) by filtering these objects by the constraints:<br>   Set-1: typegarantee.code == &quot;H&quot;<br>
   Set-2: typegarantee.code == &quot;H&quot; || typegarantee.code == &quot;O&quot;<br>   Set-3: typegarantee.code == &quot;H&quot;<br>Clearly Set-1 and Set-3 will have the same cardinality - so why compute and test it twice?<br>
Obviously, the second set will only have cardinality one if there are no &quot;garantee&quot; facts with typegarantee.code == &quot;O&quot;, and so this is a weird way of asserting that.<br><br>Cardinality tests are better written using the accumulate function &quot;count&quot;.<br>
<br>There is no point in writing<br>    $loan : loan() from $loanEvaluated.loan<br>if  $loanEvaluated.loan is not a Collection. Simply use:<br>   $loanEvaluated  : loanEvaluated(...,  $loan : loan )<br><br>The frequent use of &quot;from $loan.garantees&quot; insinuates that the &quot;garantee&quot; objects contained in the loan.garantee Collection should be inserted as facts, preferably with a link field to the &quot;loan&quot; fact they belong to. This would make evaluation much more efficient, and there wouldn&#39;t be much of repeated evaluation going on after some other rule updates loanEvaluated.<br>
<br>However, a general solution of the multiple update might still be advisable. This can be done by<br><ul><li>saving all computed update values (such as &quot;initial value&quot;) in an object S separate from loanEvaluated (possibly but not necessarily of the same type),</li>
<li><i>not </i>updating this temporary safekeeping object S,</li><li>using a low salience rule to transfer whatever is in S to the pertaining loanEvaluated. (Alternatively, you might employ agenda groups for the simple flow between main and computation.)<br>
</li></ul>-W<br><br>PS: You might adhere to the Java naming conventions using upper case initials for type names.<br>PPS: The correct spelling is &quot;g<b>u</b>arantee&quot;.<br><br><br><div class="gmail_quote">On 25 May 2011 01:55, dbfree75 <span dir="ltr">&lt;<a href="mailto:wbismuth@yahoo.fr">wbismuth@yahoo.fr</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I&#39;m still using such solution .<br>
Here an example of rule where I nees to set the<br>
originalPropertyValuationLoan :<br>
<br>
rule &quot;OriginalPropertyValuationLoan - NbSecuredGaranteeUnderLoan &gt;= 1 -<br>
garantee H - postCode equivalent - initialValue equivalent&quot;<br>
no-loop<br>
salience 970<br>
dialect &quot;mvel&quot;<br>
    when<br>
<br>
                $controlFact : ControlFact(phase == &quot;INITIAL&quot;)<br>
                $loanEvaluated  : loanEvaluated(nbSecuredGaranteeUnderLoan &gt;= 1,<br>
originalPropertyValuationLoan == null)<br>
                $loan : loan() from $loanEvaluated.loan<br>
                $garantee : garantee(typegarantee.code == &quot;H&quot; , initialValue != null) from<br>
$loan.garantees<br>
        $postCodes : Set(size == 1)<br>
                     from accumulate(<br>
                                     garantee(typegarantee.code == &quot;H&quot;, $n :<br>
postCodeInGarantee) from $loan.garantees,<br>
                                     collectSet($n)<br>
                                     )<br>
        $garantees : Set(size == 1)<br>
                     from accumulate(<br>
                                     garantee(typegarantee.code == &quot;H&quot; ||<br>
typegarantee.code == &quot;O&quot;, $n : typegarantee.code) from $loan.garantees,<br>
                                     collectSet($n)<br>
                                     )<br>
        $initialValue : Set(size == 1)<br>
                                    from accumulate(<br>
<br>
garantee(typegarantee.code == &quot;H&quot;, $n : initialValue ) from $loan.garantees,<br>
                                                    collectSet($n)<br>
                                                    )<br>
   then<br>
        $loanEvaluated.originalPropertyValuationLoan = $garantee.initialValue<br>
        update($loanEvaluated)<br>
        #System.out.println(&quot;OriginalPropertyValuationLoan -<br>
NbSecuredGaranteeUnderLoan &gt; 1 : &quot; +<br>
$loan.loanEvaluated.originalPropertyValuationLoan);<br>
end<br>
<br>
In case this rule isn&#39;t fired because any of these conditions isn&#39;t set, on<br>
update after any other property has been set  this rule will be fired again<br>
<font color="#888888"><br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Update-function-usage-for-java-objects-to-be-retrieved-for-database-update-tp2981879p2982338.html" target="_blank">http://drools.46999.n3.nabble.com/Update-function-usage-for-java-objects-to-be-retrieved-for-database-update-tp2981879p2982338.html</a><br>

</font><div><div></div><div class="h5">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">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>