Pradeep
Pradeep

Reputation: 637

How to Connect Hibernate and Drools

I'm currently working in project on rule engines and for now we have decided to use Drools... What I want to know is that if there's a way to connect hibernate session with drool knowledge session directly..... I mean if that's the case then we won't need to to insert facts one by one and drools will internally handle it...

Upvotes: 1

Views: 2212

Answers (2)

Edson Tirelli
Edson Tirelli

Reputation: 3901

Drools can load facts on demand from hibernate or any other external service, but that is only advisable for data that is used sporadically, like reference data. For that you can use the "from" keyword. E.g.:

rule X
when
   ...
   SomeReferenceData() from aDataService.fetchSomeData()
...
end

In the above example, aDataService could be a hibernate session for instance.

But again, don't use that for the data you want to reason, as it will be impossible for Drools to optimize that if you don't pre-load it.

Upvotes: 1

salaboy
salaboy

Reputation: 4143

No, you should do that. If you want to obtain your facts from the database you will need to load all the facts from the database and insert them inside the ksession. Cheers

Upvotes: 1

Related Questions