[rules-users] How to write Hibernate query lang(HQL) in .DRL file

Wolfgang Laun wolfgang.laun at gmail.com
Wed Jul 11 08:19:54 EDT 2012


If you have working Java code

   import a.b.MyService;

   MyService service = ...;
   service.aMethod(...);

then in DRL you can do

   import a.b.MyService;

   global MyService service;

   rule x when
      ...
   then
      service.aMethod(...);
   end

and in your Java code, after you create the session and before you
fire any rules you must assign an object to the global:

  MyService service = ...;
  kSession.setGlobal( "service", service );

That's all.
-W


On 11/07/2012, ashwindrool <ashwin.khandelwal86 at gmail.com> wrote:
> Hi Laune,
>
> We are tried to created similar scenario in which we get error when we
> tried
> to execute HQL from DRL file but unfortunately , i m sorry we r unable to
> give you exact what error we are getting.
>
> But it will be great if you can share your approach or process in calling
> hibernate query directly in DRL file.
> How to pass hibernate session and execute query ....if we can run simple
> select query from their , then we can go for complex nested queries.
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/How-to-write-Hibernate-query-lang-HQL-in-DRL-file-tp4018571p4018580.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list