<div>Hello,</div>
<div>&nbsp;</div>
<div>I am trying to use the EntityManager within a rule.&nbsp; I pass the EntityManager instance in from my test (currently just a mock of the interface using EasyMock) using setGlobal(&quot;em&quot;, entitymanager);</div>
<div>&nbsp;</div>
<div>so in my drls, I have:</div>
<div>&nbsp;</div>
<div>&lt;code&gt;</div>
<div>global javax.persistence.EntityManager em;</div>
<div>&lt;/code&gt;</div>
<div>&nbsp;</div>
<div>And then I use this in my LHS of the rule with a from:</div>
<div>&nbsp;</div>
<div>&lt;code&gt;</div>
<div>rule &quot;query-db&quot;</div>
<div>&nbsp; when</div>
<div>&nbsp;&nbsp;&nbsp; SampleObject(property from (em.createNativeQuery(&quot;select PROP from SAMPLEOBJECT&quot;).getResultList()))</div>
<div>&nbsp; then</div>
<div>&nbsp;&nbsp;&nbsp; System.out.println(&quot;Got an object!&quot;);</div>
<div>end</div>
<div>&lt;/code&gt;</div>
<div>&nbsp;</div>
<div>However, when I run my JUnit test, I get an error saying &quot;unexpected token &#39;PROP&#39;&quot;.&nbsp; So it looks like the Drools parser is trying to interpret what is in my string.&nbsp; Is there a special way to pass a string to the Java operation?&nbsp; Or can I simply not do this?&nbsp; How would I be able to get a result set from the db to use in pattern matching?&nbsp; The rule is dependent upon data from a table to make a decision.</div>

<div>&nbsp;</div>
<div>Thanks,</div>
<div>&nbsp;</div>
<div>David Siefert</div>