This is great. Thanks. You could then cache the food for the day in process-level cache in Hibernate which iis best used to store objects that change relatively infrequently.
Anstis, Michael (M.) wrote: > > Is this not a more viable solution? > > Global HibernateFacade hibernate; > > Rule "free food" > when > $food: Food() from hibernate.getFoodForTheDay() > $person: Person( favouriteFood == $food ) > then > System.out.println( $person.getName() + " gets a hamburger" ); > End > > Where HibernateFacade is a façade for using Hibernate named queries? > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of bchrist2 > Sent: 24 January 2008 19:02 > To: [email protected] > Subject: Re: [rules-users] Design Question > > > That makes sense. > So, if you have a rule with 2 different requirements (changes daily > versus > yearly ) > > if a persons favourite food is equal to the free food (for the day > .changes > once per day) then you would load it into the working memory as a fact > > BUT if for the same rule > if a persons favourite food is equal to the free food (for the day which > is > basically immutable..changes once per year) then you would load it into > the > global list. > > > > > > Mark Proctor wrote: >> >> 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 >>> [email protected] >>> https://lists.jboss.org/mailman/listinfo/rules-users >>> >> >> >> _______________________________________________ >> rules-users mailing list >> [email protected] >> https://lists.jboss.org/mailman/listinfo/rules-users >> >> > > -- > View this message in context: > http://www.nabble.com/Design-Question-tp15070550p15072289.html > Sent from the drools - user mailing list archive at Nabble.com. > > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > > > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > > -- View this message in context: http://www.nabble.com/Design-Question-tp15070550p15088141.html Sent from the drools - user mailing list archive at Nabble.com. _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
