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