[rules-users] Guvnor and 'from' database

Nestor Tarin Burriel nestabur at gmail.com
Mon Mar 30 03:25:05 EDT 2009


Hi,

As I understand, you dont need to put any hibernate class in guvnor. Just
try that:

Implement  a global class in your rule engine(not guvnor) with a method that
uses hibernate (for example getEntity(EntityName, Id)), then load the engine
in the same scenario as guvnor (JBOSS) and add a global class in your
package manually (if your global class is com.rule.engine.global.Global then
write the complet name in the global class of the guvnor package), save and
validate and make sure that  the package is correctly validated without any
error or warning. Now you can use the Global class of your engine in guvnor
bussiness rules as normal ;)

Then, for using your own global class you have toput it into the working
memory as follows:

        Properties props = new Properties();
        props.put("url", rulePackagePath);
        agent = RuleAgent.newRuleAgent(props);
        session = agent.getRuleBase().newStatefulSession();
com.rule.engine.global.Global global = new com.rule.engine.global.Global();
        session.setGlobal(global.getClass().getSimpleName(), global);

Hope to help you,

NEStor

2009/3/27 Anu at work <anupama.vaid at bluecasa.com>

>
> Thx. Figured that part and I did that in the source code of the execution
> server on a particular XML value coming from client.
>
> I suppose now I have to put hibernate in Guvnor's classpath, declare a
> global variable in the package configuration and then use it in a rule.
>
> One thing I cannot figure out is where to put the hibernate xml config file
> in guvnor. Can you help?
>
> Thx
>
>
> Mark Proctor wrote:
> >
> > Anu at work wrote:
> >> I am trying to use drools to evaluate the following rule:
> >>
> >> Given a telephone number, if the telephone number already exists in
> >> database
> >> and has a balance > 0, set isAllowed = false.
> >>
> >> Looking at forum posts I understand that this can be achieved using
> >> hibernate and 'from' keyword. However, this is my current scenario - I
> >> create a package snapshot for my rules in Guvnor and use the URL in
> >> Drools
> >> execution server. Execution server runs only stateless sessions.
> >>
> >> Where and how do I use hibernate named queries?
> >>
> > set the hibernate session as a global and then the 'from' can access it.
> >> Thx,
> >> Anu
> >>
> >>
> >>
> >
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Guvnor-and-%27from%27-database-tp22745198p22747661.html
> Sent from the drools - user mailing list archive at Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090330/994700d1/attachment.html 


More information about the rules-users mailing list