On 3/9/07, Uday Kamath <UKamath(a)dharbor.com> wrote:
We had similar use case. What we do is we model the Schema elements,
generate Java Beans (pojo), and write rules using these Pojo. Now we have
written a Service on top which takes Hibernate QL and gets the database
records as the same Pojos that Rules are defined on and fire the Rules. Thus
the service is generic and can be changed to take any Query. The Rules can
me modified and changed anytime and redeployed but business objects in form
of Pojos remain the same. Hope this helps
[mailto:firstname.lastname@example.org] On Behalf Of
Sent: Friday, March 09, 2007 3:53 AM
Subject: [rules-users] Using rules with database scenario
First time trying to learn JBoss Rules here. We have a pretty large
database (DBMS), we want to build some rules and retrieve data based on the
Could someone give a hint or an example of this usage scenario? I mean, how
can I use rules for database query, without writing my rules in SQL
directly? We are currently writing everything in HQL (Hibernate), but the
rules change every 3 months on average, so that's not a way to maintain the
system. Therefore, we want to extract that portion of the business logic out
of the code. The data structure does not change, but the rules keep on
I'm reading the user's guide, running thru the examples, writing some of my
own, but still no clue how to make it work with database.
If someone could give a sample, that would be greatly appreciated.
Thanks a lot.
That's probably the best solution. Using the current version (3.1M1),
you can use the FROM keyword to reference facts from List object
returned from a method call on a service, for example.
Something like this works very good in my current testing project:
MyObject( someValue = "foobar" ) from MyObjectDAO.loadAll()
The DAO then uses Hibernate to load some objects and returns a
List<MyObject> which can be used by Drools.
As Uday already wrote, you could also write a DAO which retrieves
arbitrary objects using a given HQL statement.