Globals cannot to be used - directly or indirectly - as objects that should trigger<br>the firing of rules. It is only insert, modify or update, and retract that cause (re-)evaluation of LHS conditions.<br><br>-W <br><br><div class="gmail_quote">
On 31 October 2011 15:05, elsdestickere <span dir="ltr">&lt;<a href="mailto:elsdestickere@yahoo.com">elsdestickere@yahoo.com</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;">
Hi,<br>
<br>
I read docs about global and Hibernate to access your DB from the rules.<br>
I tried something simular for in memory DAO&#39;s.<br>
But some rules fire (&quot;WM&quot; in RHS) as the DAO has 3 items, but others (&quot;dao&quot;<br>
in LHS) don&#39;t, how is that possible?<br>
<br>
global RepositoryFactory repFact;<br>
rule &quot;dao&quot;<br>
    when<br>
       k : Customer(  ) from repFact.getCustomerRepository().findAll();<br>
    then<br>
        System.out.println( &quot;Drools &quot;+drools.getRule().getName()+&quot;: &quot;<br>
+k.getName());<br>
end<br>
rule &quot;WM&quot;<br>
    when<br>
       k : Customer(  ) ;<br>
    then<br>
        System.out.println( &quot;Drools &quot;+drools.getRule().getName()+&quot;: &quot;<br>
+k.getName()+&quot; + size: &quot;+repFact.getCustomerRepository().findAll().size());<br>
end<br>
...<br>
RepositoryFactory repFact = Registry.getRepositoryFactory();<br>
ksession.setGlobal(&quot;repFact&quot;, repFact);<br>
...<br>
CustomerRepository customerRepo = Registry.getRepositoryFactory()<br>
                                .getCustomerRepository();<br>
customerRepo.add(tom);<br>
customerRepo.add(elise);<br>
customerRepo.add(bert);<br>
ksession.insert(bert);<br>
ksession.fireAllRules();<br>
<br>
...<br>
Output:<br>
Drools WM: Bert + size: 3<br>
<br>
br,<br>
Els<br>
<font color="#888888"><br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/global-as-link-to-DB-different-results-tp3467897p3467897.html" target="_blank">http://drools.46999.n3.nabble.com/global-as-link-to-DB-different-results-tp3467897p3467897.html</a><br>

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>
</font></blockquote></div><br>