]
Luca Molteni closed DROOLS-3527.
--------------------------------
Resolution: Done
executable-model fails to compare BigDecimal
--------------------------------------------
Key: DROOLS-3527
URL:
https://issues.jboss.org/browse/DROOLS-3527
Project: Drools
Issue Type: Bug
Components: executable model
Affects Versions: 7.16.0.Final
Reporter: Toshiya Kobayashi
Assignee: Luca Molteni
Priority: Major
Labels: support
When executable-model builds BigDecimal constraint, BigDecimal(double) constructor is
used hence fails to compare at runtime.
It generates source code like this:
{code:java}
public class Rules64ef7d59a364454aa08fdda838c67ad1RuleMethods0 {
/**
* Rule name: R1
*/
public static org.drools.model.Rule rule_R1() {
final org.drools.model.Variable<com.sample.Customer> var_$customer =
D.declarationOf(com.sample.Customer.class,
"$customer");
org.drools.model.Rule rule = D.rule("com.sample",
"R1").build(D.pattern(var_$customer).expr("$expr$1$",
(_this) ->
org.drools.modelcompiler.util.EvaluationUtil.equals(org.drools.modelcompiler.util.EvaluationUtil.toBigDecimal(_this.getRate()),
org.drools.modelcompiler.util.EvaluationUtil.toBigDecimal(12.111)),
D.alphaIndexedBy(java.math.BigDecimal.class,
org.drools.model.Index.ConstraintType.EQUAL,
0,
_this -> _this.getRate(),
new java.math.BigDecimal("12.111")),
D.reactOn("rate")),
D.execute(() -> {
System.out.println("hello");
}));
return rule;
}
}
{code}
I think org.drools.modelcompiler.util.EvaluationUtil.toBigDecimal(12.111) is the problem.