Hello,

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);

so in my drls, I have:

<code>
global javax.persistence.EntityManager em;
</code>

And then I use this in my LHS of the rule with a from:

<code>
rule "query-db"
  when
    SampleObject(property from (em.createNativeQuery("select PROP from
SAMPLEOBJECT").getResultList()))
  then
    System.out.println("Got an object!");
end
</code>

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.

Thanks,

David Siefert
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to