[rules-users] Design Question
Mark Proctor
mproctor at codehaus.org
Thu Jan 24 12:53:00 EST 2008
Christie, Blair wrote:
>
> Does anyone have any examples of using the new 'from' element it is
> now common to pass a Hibernate session as a global, to allow 'from' to
> pull data from a named Hibernate query.
>
>
>
> Would it be good design to store the values for a condition in a
> database so they can be changed without having to go into the .drl file?
>
>
>
> i.e.
>
> So instead of ..
>
>
>
> Rule "free food"
>
> when
>
> Food( $food : name == "hamburger" )
>
> $: Person( favouriteFood == $food )
>
> then
>
> System.out.println( $person.getName() + " gets a hamburger" );
>
> End
>
>
>
> You would have
>
>
>
> global Food food //where food is inserted as a global but populated
> from a db.
>
>
>
> Rule "free food"
>
> when
>
> $food : food
>
> $person: Person( favouriteFood == $food )
>
> then
>
> System.out.println( $person.getName() + " gets a " +
> $food.getName() );
>
> End
>
>
>
> Cheers,
>
>
>
> Blair
>
No that isn't good, due to indexing. If $food changes value without the
engine knowing about it, then you get a memory leak. So you have to
assert the value. Globals really are for immutable vars or containers to
collect results.
>
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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/20080124/262fae4f/attachment.html
More information about the rules-users
mailing list