Hibernate Configuration with Drools 5.4
by zeeshan
Hi All !
I want to use Hibernate for database persistence in my drools project.
Please suggest me the steps. I am using 5.4.0 final version. Which version
of hibernate I shall use whether 3.1 or Annotation one.....?? I have idea
about 3.1. Actually I am having 50,000 records in one of my Decision table,
so it is taking too much time to give the result. Now I have decided to use
move this to database. So please tell me configuration steps.
Thanks !!
--
View this message in context: http://drools.46999.n3.nabble.com/Hibernate-Configuration-with-Drools-5-4...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
NullPointerException using 'enabled' function.
by groovenarula
I'm trying to use the enabled function to ensure that some rules only fire
under certain conditions.
I have the following in my DRL :
rule "Load pricelist"
salience 10000
when
$unitPrice : Pricelist() from PricelistUtilities.getPriceLists()
then
insert ($unitPrice);
end
rule "Retract a priced unit"
salience 5000
when
$priceUnit : PriceUnit( basePrice != null )
then
System.out.println("Retracting ..." + $priceUnit);
retract ( $priceUnit );
end
rule "Price Unit by Prodid, Grade, Pattern, Color"
enabled ( $detailPrice == true )
salience 2500
when
$priceUnit : PriceUnit ( $detailPrice : detailPrice )
$priceList : Pricelist( prodid == $priceUnit.prodid, coverGrade ==
$priceUnit.coverGrade, coverSeries == $priceUnit.coverSeries, coverColor ==
$priceUnit.coverColor )
then
modify ( $priceUnit ) {
setBasePrice ( $priceList.getBasePrice() );
}
end
rule "Price Unit by Prodid, Grade, Pattern"
enabled ( $detailPrice == true )
salience 2000
when
$priceUnit : PriceUnit ( $detailPrice : detailPrice )
$priceList : Pricelist( prodid == $priceUnit.prodid, coverGrade ==
$priceUnit.coverGrade , coverSeries == $priceUnit.coverSeries )
then
modify ( $priceUnit ) {
setBasePrice ( $priceList.getBasePrice() );
}
end
rule "Price Unit by Prodid, Grade, Pattern 0000"
salience 1500
when
$priceUnit : PriceUnit ( )
$priceList : Pricelist( prodid == $priceUnit.prodid, coverGrade ==
$priceUnit.coverGrade , coverSeries == "0000" )
then
System.out.println("Pricing unit : " + $priceUnit + " from " +
$priceList);
$priceUnit.setBasePrice($priceList.getBasePrice());
update ( $priceUnit );
end
Before adding the 'enabled' conditions to the rules, it all worked fine. But
after adding the 'enabled' function, I'm getting the following NullPointer
exception :
Exception executing consequence for rule "Price Unit by Prodid, Grade,
Pattern 0000" in com.sample: java.lang.NullPointerException
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1283)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1209)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1442)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230)
at com.generic.rules.utils.DroolsTest.main(DroolsTest.java:37)
Caused by: java.lang.NullPointerException
at org.drools.common.DefaultAgenda.createActivation(DefaultAgenda.java:569)
at
org.drools.reteoo.RuleTerminalNode.modifyLeftTuple(RuleTerminalNode.java:297)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateModifyChildLeftTuple(SingleLeftTupleSinkAdapter.java:246)
at org.drools.reteoo.JoinNode.modifyLeftTuple(JoinNode.java:363)
at
org.drools.reteoo.LeftTupleSource.doModifyLeftTuple(LeftTupleSource.java:297)
at
org.drools.reteoo.LeftTupleSource.modifyLeftTuple(LeftTupleSource.java:271)
at org.drools.reteoo.JoinNode.modifyLeftTuple(JoinNode.java:429)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateModifyObject(CompositeLeftTupleSinkAdapter.java:260)
at
org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateModifyObject(CompositeLeftTupleSinkAdapter.java:275)
at
org.drools.reteoo.LeftInputAdapterNode.modifyObject(LeftInputAdapterNode.java:170)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:507)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:432)
at org.drools.reteoo.ObjectTypeNode.modifyObject(ObjectTypeNode.java:314)
at org.drools.reteoo.EntryPointNode.modifyObject(EntryPointNode.java:265)
at org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:470)
at org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:370)
at
org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:317)
at
org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:312)
at
com.sample.Rule_Price_Unit_by_Prodid__Grade__Pattern_0000_8fe2d406670448989b7e4f1e051a27e9.defaultConsequence(Rule_Price_Unit_by_Prodid__Grade__Pattern_0000_8fe2d406670448989b7e4f1e051a27e9.java:9)
at
com.sample.Rule_Price_Unit_by_Prodid__Grade__Pattern_0000_8fe2d406670448989b7e4f1e051a27e9DefaultConsequenceInvokerGenerated.evaluate(Unknown
Source)
at
com.sample.Rule_Price_Unit_by_Prodid__Grade__Pattern_0000_8fe2d406670448989b7e4f1e051a27e9DefaultConsequenceInvoker.evaluate(Unknown
Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1273)
... 6 more
In the console I also see the results of my System.out.println :
Pricing unit : PriceUnit [prodid=001001, coverGrade= A, coverSeries=1234,
coverColor=05, basePrice=null] from Pricelist [prodid=001001, cover=
A0000null, basePrice=599]
The only 'null' is $priceUnit.basePrice, which is what I'm trying to set.
I only get the exception when the 'detailedPrice' of PriceUnit is set to
false (i.e. when "Price Unit by Prodid, Grade, Pattern 0000" is attempting
to fire. If I set detailedPrice to true, the other rules fire just fine.
If I comment out the 'update ( $priceUnit );', the consequence fires just
fine, but then other rules fire as well. When PriceUnit's pattern is set to
anything other than '1234', then too consequence of ""Price Unit by Prodid,
Grade, Pattern 0000"" rule fires just fine and I get the following output
(correctly so) :
Pricing unit : PriceUnit [prodid=001001, coverGrade= A, coverSeries=3456,
coverColor=05, basePrice=null] from Pricelist [prodid=001001, cover=
A0000null, basePrice=599]
Retracting ...PriceUnit [prodid=001001, coverGrade= A, coverSeries=3456,
coverColor=05, basePrice=599]
What is causing the 'NullPointerException' ?
I'm using Drools 5.4.0.
Please help.
G
--
View this message in context: http://drools.46999.n3.nabble.com/NullPointerException-using-enabled-func...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 4 months
Drools Performance
by elena_nardini@libero.it
Hi,
I am wondering about using Drools rule engine.
I have to threat with a large data set, so I would like to know about rule
engine performance.
Could someone help me?
Thanks a lot,
Elena
12 years, 4 months