[rules-users] Problem Comparing to Character Fields

BrianKE brianke at gmail.com
Thu Jun 14 14:20:27 EDT 2007


After asserrting the following objects and performing the rule I get the error 
shown
 
        PersonSummary personSummary = new PersonSummary();
        personSummary.setPrId(new Long(217));
        personSummary.setCmpntCd(new Character('R'));
 
        PersonSummary personSummary2 = new PersonSummary();
        personSummary2.setPrId(new Long(217));
        personSummary2.setCmpntCd(new Character('G'));
 
##################################
 
rule "Duplicate Projection for same processing date by another component"
	when
		$j : PersonSummary($prId : prId, $cmpntCd : cmpntCd)
		exists PersonSummary(this != $j, cmpntCd == $cmpntCd)
	then
		System.out.println("Error Found in rule Duplicate Component 
Code");
end
 
##################################
 
java.lang.ClassCastException: 
org.drools.rule.VariableRestriction$ObjectVariableContextEntry
	at 
org.drools.base.evaluators.CharacterFactory$CharacterEqualEvaluator.evaluateCac
hedRight(CharacterFactory.java:99)
	at org.drools.rule.VariableRestriction.isAllowedCachedRight
(VariableRestriction.java:78)
	at org.drools.rule.VariableConstraint.isAllowedCachedRight
(VariableConstraint.java:78)
	at org.drools.common.DoubleBetaConstraints.isAllowedCachedRight
(DoubleBetaConstraints.java:149)
 


If I change the exists rule to:
 
    exists PersonSummary(this != $j, cmpntCd == 'A')
 
it works fine.
 
Is there something I have to do to compare two char objects.
 
Thanks




More information about the rules-users mailing list