<br>&nbsp;&nbsp; Shaz,<br><br>&nbsp;&nbsp; We strongly advise you to move to 4.0.3, but this is not related to your problem. <br>&nbsp;&nbsp; I think you are misunderstanding something. Why are you using the global map to store your fact? Simply insert it into the working memory and it will work fine.
<br><br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br><br><br><div><span class="gmail_quote">2007/11/1, Shaz Tumulak &lt;<a href="mailto:shauii@yahoo.com">shauii@yahoo.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>Hi,<br><br>I can&#39;t seem to make this syntax work in Drools 4.0.2. Pls. see my sample<br>code below.<br>________________________________________<br>class MyClass {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String id;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String name;<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyClass(String id, String name){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://this.id">this.id</a> = id;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://this.name">this.name</a> = name;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getter, setter methods
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:<br>}<br><br>MyClass obj = new MyClass(&quot;1&quot;&quot;, &quot;name&quot;);<br><br>TreeMap&lt;String, MyClass&gt; mapOfObj = new TreeMap&lt;String, MyClass&gt;();<br>mapOfObj.put(&quot;keyOfObj&quot;, obj);
<br>________________________________________<br><br>DRL file<br>-------<br><br>global java.util.TreeMap mapOfObj;<br><br>rule chkobj<br>when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;obj : MyClass(mapOfObj[&quot;keyOfObj&quot;].id == &quot;1&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eval(obj.getName() == &quot;name&quot;);<br>________________________________________<br><br>I&#39;m getting this error: org.drools.RuntimeDroolsException:<br>java.lang.NullPointerException<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at
<br>org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:76)<br><br>Is my syntax correct and has someone used this in 4.0.2 or should I move on<br>to Drools 4.0.3? Thanks in advance.<br><br>Regards,<br><br>shaz<br><br>
<br>Edson Tirelli-3 wrote:<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Denis,<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;If you are using latest build from trunk (I&#39;m not sure it already works<br>&gt; in MR3), you can use a simplified MVEL syntax:<br>&gt;<br>&gt; when
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; Person( address[&quot;business&quot;].phone == &quot;99999999&quot; )<br>&gt; then<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; ...<br>&gt; end<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Although, the above will be converted into an inline-eval. Not as bad<br>&gt; as
<br>&gt; a top level eval, but still more costly then using regular fields.<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;[]s<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Edson<br>&gt;<br>&gt; 2007/7/19, Ryan, Dennis (Dennis) &lt;<a href="mailto:dennisryan@avaya.com">dennisryan@avaya.com
</a>&gt;:<br>&gt;&gt;<br>&gt;&gt;&nbsp;&nbsp;We are using Maps (HashMaps) in our rules and the only way we have found<br>&gt;&gt; to access keys and values in the Map in the &quot;when&quot; clauses is thru use on<br>&gt;&gt; eval() which I know is a big no-no by rules purists. Is there a better
<br>&gt;&gt; way,<br>&gt;&gt; maybe some shorthand I&#39;m not familiar with to deal with Maps in the when<br>&gt;&gt; clause?<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt; Thanks,<br>&gt;&gt;<br>&gt;&gt; Dennis<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;&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><a href="mailto:shauii@yahoo.com">shauii@yahoo.com</a><br>--<br>View this message in context: <a href="http://www.nabble.com/Accessing-maps-%28hashmaps%29-keys-and-values-in-rules-tf4112197.html#a13524477">http://www.nabble.com/Accessing-maps-%28hashmaps%29-keys-and-values-in-rules-tf4112197.html#a13524477
</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>