<br>&nbsp;&nbsp;&nbsp; Well, it must work. Can you open a JIRA with a self contained test case please? I will investigate.<br><br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br><br><div><span class="gmail_quote">2007/8/22, pentarious &lt;<a href="mailto:cristiano.giuffrida@gmail.com">
cristiano.giuffrida@gmail.com</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>I know. Actually I didn&#39;t put any update or insert statement in the code just
<br>to make it simpler. The actual code looks like:<br>when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$itemList : ArrayList() from collect( Item( category == &quot;VIDEO&quot; ) )<br>then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ItemDiscount disc = new ItemDiscount(10);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;insert(disc);
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$myFirstItem = (Item)$itemList.get(0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$mySecondItem = (Item)$itemList.get(1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$myFirstItem.addDiscount(disc);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$mySecondItem.addDiscount(disc);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;update($myFirstItem);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;update($mySecondItem);
<br>Now, why this doesn&#39;t work at all? It does work if I write a rule for each<br>item using in the when clause $item&nbsp;&nbsp;: Item from $itemList, but as I said I<br>need to write a list-oriented rule.<br><br>Regards,<br><br>
CG<br><br><br>Edson Tirelli-3 wrote:<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;If you want the &quot;engine to see&quot; your changes, in a way you affect other<br>&gt; rules, you must call update( object ) for the object you are changing.<br>&gt; Otherwise, the change will happen to the original object, but not to the
<br>&gt; shadow proxy that the engine uses to ensure consistency.<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;[]s<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Edson<br>&gt;<br>&gt; 2007/8/22, pentarious &lt;<a href="mailto:cristiano.giuffrida@gmail.com">cristiano.giuffrida@gmail.com
</a>&gt;:<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt; Ok, I&#39;m still working on that, I&#39;ll publish my solution asap. In the<br>&gt;&gt; meantime<br>&gt;&gt; it turns out our requirements need something more than that. We have an
<br>&gt;&gt; ordered list of beans (items) and we have to be able to modify a specific<br>&gt;&gt; subset of the list (adding a discount). Now I tried to solve this problem<br>&gt;&gt; by<br>&gt;&gt; working directly on the list of items. But I can&#39;t understand why this
<br>&gt;&gt; doesn&#39;t work:<br>&gt;&gt; when<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$itemList : ArrayList() from collect( Item( category == &quot;VIDEO&quot; ) )<br>&gt;&gt; then<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ItemDiscount disc = new ItemDiscount(10);<br>
&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$myFirstItem = (Item)$itemList.get(0);<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$mySecondItem = (Item)$itemList.get(1);<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$myFirstItem.addDiscount(disc);<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$mySecondItem.addDiscount(disc);<br>&gt;&gt;<br>
&gt;&gt; After executing this rule it&#39;s like nothing happened! I mean no discount<br>&gt;&gt; has<br>&gt;&gt; been added to the two items! The problem seems to be related to<br>&gt;&gt; extracting<br>&gt;&gt; items from the list. Apparently, every time we get an item from the list,
<br>&gt;&gt; it<br>&gt;&gt; looses its link with the original item (I don&#39;t know if it&#39;s a copy of<br>&gt;&gt; the<br>&gt;&gt; original item or whatever), so that every update doesn&#39;t affect the<br>&gt;&gt; original
<br>&gt;&gt; item any more. But of course that&#39;s what we&#39;re interested in! We want to<br>&gt;&gt; modify original items in the rule session. Am I missing something? Or Is<br>&gt;&gt; it<br>&gt;&gt; a bug?<br>&gt;&gt;
<br>&gt;&gt; Regards,<br>&gt;&gt;<br>&gt;&gt; CG<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt; Edson Tirelli-3 wrote:<br>&gt;&gt; &gt;<br>&gt;&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; Please, share with us! Send to the list!<br>&gt;&gt; &gt;<br>&gt;&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; Edson
<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; 2007/8/21, pentarious &lt;<a href="mailto:cristiano.giuffrida@gmail.com">cristiano.giuffrida@gmail.com</a>&gt;:<br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt; I found an interesting implementation to do that. If anyone is
<br>&gt;&gt; interested<br>&gt;&gt; &gt;&gt; I<br>&gt;&gt; &gt;&gt; could share my solution.<br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt; Regards,<br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt; CG<br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt;
<br>&gt;&gt; &gt;&gt; Mark Proctor wrote:<br>&gt;&gt; &gt;&gt; &gt;<br>&gt;&gt; &gt;&gt; &gt; There is no supported way to do this. You could use an inline-eval<br>&gt;&gt; &gt;&gt; &gt; against a global, but that is very clunkey. However it does seem
<br>&gt;&gt; like<br>&gt;&gt; a<br>&gt;&gt; &gt;&gt; &gt; good feature idea for a future release, open a jira and I&#39;ll look<br>&gt;&gt; into<br>&gt;&gt; &gt;&gt; &gt; getting it included.<br>&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; &gt; Mark<br>&gt;&gt; &gt;&gt; &gt; pentarious wrote:<br>&gt;&gt; &gt;&gt; &gt;&gt; Does anyone know a method to limit the number of results from a<br>&gt;&gt; &gt;&gt; collect<br>&gt;&gt; &gt;&gt; &gt;&gt; statement? I was just wondering how to do something like this:
<br>&gt;&gt; &gt;&gt; &gt;&gt; $myList : List() from collect( MyObject(myField == &quot;something&quot;) )<br>&gt;&gt; &gt;&gt; limit<br>&gt;&gt; &gt;&gt; 3<br>&gt;&gt; &gt;&gt; &gt;&gt; //it should put in $myList just the first 3 objects retrieved
<br>&gt;&gt; &gt;&gt; &gt;&gt; I&#39;m quite sure there is nothing in Drools which can natively<br>&gt;&gt; support<br>&gt;&gt; &gt;&gt; &gt;&gt; something like that. So, how to do that, if needed? I tried this,<br>&gt;&gt; but
<br>&gt;&gt; &gt;&gt; it<br>&gt;&gt; &gt;&gt; &gt;&gt; seems not to be working (I can&#39;t understand why, though):<br>&gt;&gt; &gt;&gt; &gt;&gt; $myList : List() from collect( MyObject(myField == &quot;something&quot;) )
<br>&gt;&gt; &gt;&gt; &gt;&gt; $myObject : MyObject() from $myList<br>&gt;&gt; &gt;&gt; &gt;&gt; eval( $myList.indexOf($myObject) &lt; 3 )<br>&gt;&gt; &gt;&gt; &gt;&gt; Indeed, it doesn&#39;t work because the link beetween $myList and
<br>&gt;&gt; &gt;&gt; $myObject<br>&gt;&gt; &gt;&gt; &gt;&gt; seems to be released during any execution of the rule (In fact<br>&gt;&gt; &gt;&gt; &gt;&gt; $myList.contains($myObject) returns false! Again, I can&#39;t<br>&gt;&gt; understand
<br>&gt;&gt; &gt;&gt; &gt;&gt; why...)<br>&gt;&gt; &gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt; &gt;&gt; Any advice would be really appreciated!<br>&gt;&gt; &gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt; &gt;&gt; Regards,<br>&gt;&gt; &gt;&gt; &gt;&gt;
<br>&gt;&gt; &gt;&gt; &gt;&gt; CG<br>&gt;&gt; &gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt; &gt;<br>&gt;&gt; &gt;&gt; &gt; _______________________________________________<br>&gt;&gt; &gt;&gt; &gt; rules-users mailing list<br>&gt;&gt; &gt;&gt; &gt; 
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>&gt;&gt; &gt;&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
<br>&gt;&gt; &gt;&gt; &gt;<br>&gt;&gt; &gt;&gt; &gt;<br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;&gt; --<br>&gt;&gt; &gt;&gt; View this message in context:<br>&gt;&gt; &gt;&gt;<br>&gt;&gt; <a href="http://www.nabble.com/How-to-limit-results-from-a-collect-statement-tf4235669.html#a12249025">
http://www.nabble.com/How-to-limit-results-from-a-collect-statement-tf4235669.html#a12249025</a><br>&gt;&gt; &gt;&gt; Sent from the drools - user mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br>&gt;&gt; &gt;&gt;
<br>&gt;&gt; &gt;&gt; _______________________________________________<br>&gt;&gt; &gt;&gt; rules-users mailing list<br>&gt;&gt; &gt;&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>&gt;&gt; &gt;&gt; 
<a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>&gt;&gt; &gt;&gt;<br>&gt;&gt; &gt;<br>&gt;&gt; &gt;<br>&gt;&gt; &gt;<br>&gt;&gt; &gt; --<br>&gt;&gt; &gt;&nbsp;&nbsp; Edson Tirelli
<br>&gt;&gt; &gt;&nbsp;&nbsp; Software Engineer - JBoss Rules Core Developer<br>&gt;&gt; &gt;&nbsp;&nbsp; Office: +55 11 3529-6000<br>&gt;&gt; &gt;&nbsp;&nbsp; Mobile: +55 11 9287-5646<br>&gt;&gt; &gt;&nbsp;&nbsp; JBoss, a division of Red Hat @ <a href="http://www.jboss.com">
www.jboss.com</a><br>&gt;&gt; &gt;<br>&gt;&gt; &gt; _______________________________________________<br>&gt;&gt; &gt; rules-users mailing list<br>&gt;&gt; &gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org
</a><br>&gt;&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>&gt;&gt; &gt;<br>&gt;&gt; &gt;<br>&gt;&gt;<br>&gt;&gt; --<br>&gt;&gt; View this message in context:
<br>&gt;&gt; <a href="http://www.nabble.com/How-to-limit-results-from-a-collect-statement-tf4235669.html#a12270505">http://www.nabble.com/How-to-limit-results-from-a-collect-statement-tf4235669.html#a12270505</a><br>&gt;&gt; Sent from the drools - user mailing list archive at 
<a href="http://Nabble.com">Nabble.com</a>.<br>&gt;&gt;<br>&gt;&gt; _______________________________________________<br>&gt;&gt; rules-users mailing list<br>&gt;&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org
</a><br>&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>&gt;&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; --<br>&gt;&nbsp;&nbsp; Edson Tirelli<br>&gt;&nbsp;&nbsp; Software Engineer - JBoss Rules Core Developer
<br>&gt;&nbsp;&nbsp; Office: +55 11 3529-6000<br>&gt;&nbsp;&nbsp; Mobile: +55 11 9287-5646<br>&gt;&nbsp;&nbsp; JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>&gt;<br>&gt; _______________________________________________
<br>&gt; rules-users mailing list<br>&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users
</a><br>&gt;<br>&gt;<br><br>--<br>View this message in context: <a href="http://www.nabble.com/How-to-limit-results-from-a-collect-statement-tf4235669.html#a12272536">http://www.nabble.com/How-to-limit-results-from-a-collect-statement-tf4235669.html#a12272536
</a><br>Sent from the drools - user mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br><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">https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote></div><br><br clear="all"><br>-- <br>&nbsp;&nbsp;Edson Tirelli
<br>&nbsp;&nbsp;Software Engineer - JBoss Rules Core Developer<br>&nbsp;&nbsp;Office: +55 11 3529-6000<br>&nbsp;&nbsp;Mobile: +55 11 9287-5646<br>&nbsp;&nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>