As a general rule, query the database in the Java code, and insert the objects retrieved
as facts in the session. Then your LHS just needs to match on those facts. Either that or
populate a global.
If you have a stateless session, then you could get away with facts with getter methods
which return collections and which are actually calling the database. However, it's
horribly inefficient, more error prone (for one thing, you can't put a try-catch in
your LHS) and less readable than performing the database queries up front in your Java
code.
fyi - On my last contract, the main reason I was able to achieve a ~1000x speed gain was
removing database queries from the LHS and instead performing them up front and inserting
the results as facts via the Java API.
Steve
On 30 Aug 2013, at 18:47, rtanikella <rtanikella(a)gmail.com> wrote:
Hi,
I am using Drools Server 5.4.0.Final as a web application deployed on JBoss
AS 7.1.1.Final, and Guvnor 5.4.0.Final for authoring/managing the business
rules.
I need to get data from a relational database (and eventually any other
external system) into the WHEN clause of any rule in the Guvnor, and, if
needed, be able to insert that data into the working memory via the THEN
clause. What is the best approach in achieving this? If there are any
examples or samples, please point them out.
Thanks,
Ramgopal Tanikella
--
View this message in context:
http://drools.46999.n3.nabble.com/Getting-data-from-a-relational-database...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users