Wednesday, July 9, 2008

Drools meets Hibernate

Drools evaluates facts which are present in the working memory. But it can also reason over data stored in a relational database. This can be achieved using for example a Hibernate Session to access a relational database and then creating a query. Objects in the resultset can be reasoned over the same way like facts in the working memory. An article, which describes this is available in English, German and Polish.

Labels: , ,

14 Comments:

At August 12, 2008 at 9:14 PM , Blogger Ramesh M said...

Hi,

It is really excellent idea. But how will this work in case spring managed hibernate session and transaction management.

Please show me some pointers if you have any. Or please e-mail me at ramesh dot mandaleeka at gmail.com

Regards,
Ramesh

 
At August 14, 2008 at 12:31 PM , Blogger Jaroslaw Kijanowski said...

Actually this is a Spring/Hibernate question and I'm not too confident to answer it since I haven't tried it. But you're welcome to leave a comment if you find out something interesting.

Cheers.

 
At March 23, 2010 at 9:03 PM , Blogger N0m0r3l13s said...

While this example is good to show how to access facts to external memories. I find it a little bit useless.

Because you have to rewrite all your rules to match the rule constraints in your query. So the engine really does not match anything but your queries.

It would be great if drools will generate the HQL based on the condition part (LHS) and obtain result automagically...

This way you have not to rewrite your rules with SQL/HQL and will work without user intervention. What's great.

But I think that's not possible. Don't you think?

 
At October 26, 2010 at 2:55 PM , Anonymous house rental said...

This comment has been removed by a blog administrator.

 
At January 13, 2011 at 9:54 PM , Anonymous Prasanth James said...

very nice article.

 
At June 18, 2012 at 1:32 PM , Anonymous Anonymous said...

Hi ! Nice artilce....nut I am getting nul pointer exception. I am using drools 5.4 please help me in this....

Thanks !

 
At June 18, 2012 at 1:32 PM , Blogger Unknown said...

Hi ! Nice artilce....nut I am getting nul pointer exception. I am using drools 5.4 please help me in this....

Thanks !

 
At June 18, 2012 at 1:32 PM , Blogger Unknown said...

Hi ! Nice artilce....nut I am getting nul pointer exception. I am using drools 5.4 please help me in this....

Thanks !

 
At October 9, 2012 at 2:02 PM , Blogger Unknown said...

Hi,
It is a very good article.I want to know how can i use named query in drools-guvnor ,Can you please provide me a example?

 
At December 5, 2012 at 12:55 PM , Anonymous Anonymous said...

Hi,

Its really nice.
But I couldn't get the result from hibernate query. The syntax is correct and there is no parser error.

Kindly help me what could cause this.

 
At December 5, 2012 at 1:04 PM , Anonymous Anonymous said...

Hi,

Below is the query.
For time being i hard coded the student id.While running there is no error. But i couldn't get the values from this query.


$student : Student() from hibernateSession.createQuery("select name from Student where studentId = :studId").setProperties(["studId" : Long.valueOf(553747)]).list()


Plz help me, its urgent.

Thanks in advance.

Thanks,
Rose

 
At December 6, 2012 at 5:31 AM , Anonymous Anonymous said...

Hi,
I got the answer.

wrong:

$student : Student() from hibernateSession.createQuery("select name from Student where studentId = :studId").setProperties(["studId" : Long.valueOf(553747)]).list()

correct:
$student : Student() from hibernateSession.createQuery("from Student where studentId = :studId").setProperties(["studId" : Long.valueOf(553747)]).list()


Thanks.

 
At October 4, 2013 at 7:40 AM , Anonymous Anonymous said...

Nice article, easy to follow

 
At April 3, 2014 at 9:14 PM , Blogger Hong Ju said...

Very helpful article, there aren't many articles regarding this topic.

I have saved all my Drools facts data in SQL via Hibernate, however, every time, when I start my application, Drools has to load my entire database into memory which will take multiple hours to load, I can see Hibernate is doing select statements during loading the Drools session. This application is not useful because of this.

I wonder if there is a way to configure to avoid this. Any idea will be helpful.

Thanks a lot.

 

Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home