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@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users