Drools spring hibernate load rules from database
Drools is a business rule management system (rules engine). there are multiple ways to define and process rules. 1. define rules in drl file and this .drl file can be saved in resources. 2. define template in .drt file (in code resources) and load rules from excel file. 3. define template in .drt file and load rules from database. option 3 is little tricky in hibernate where it takes input only in java.sql.ResultSet format. Implementation for option 3 is as below. sample drt file template header id rule_type agenda_group activation_group salience when_logic then_logic package com.sample; import java.util.Arrays; import java.util.ArrayList; import java.lang.Long; template "sample_rule" rule "sample_@{id}_@{rule_type}" agenda-group "@{agenda_group}" activation-group "@{activation_group}" salience @{salience} when @{when_logic} then @{then_logic} end end template assume you have columns in database table (eg- rule) id,rule_typ