[jboss-user] [JBoss Seam] - Re: Drools (JBoss Rules) Hibernate Query and EntityManager

ellenzhao do-not-reply at jboss.com
Thu Jul 19 11:24:16 EDT 2007


You can tie Seam and Drools like this:

In your conversation bean, you say:

  | ...
  | @In
  | private RuleBase myRuleBase; // you must have already this rule base defined in your component.xml. Please refer to Seam manual.
  | ...
  | public void eatCheese(){
  |   // you can also use stateful rule session here. Please refer to Drools' manual
  |   StatelessSession ruleSession = myRuleBase.newStatelessSession();
  |   ruleSession.setGlobal("entityManager", entityManager);
  |   ruleSession.setGlobal("anotherResource", anotherResource);
  |   ...
  |   ruleSession.execute(cheeseList);
  | }
  | ...

In your .drl file, you can define the entityManager as global so all your rules in that rule package can share this single entityManager. You can ask entityManager to fetch the data you want at LHS and do things like entityManager.flush() at RHS. 


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4065864#4065864

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4065864

More information about the jboss-user mailing list