[jboss-jira] [JBoss JIRA] (DROOLS-897) Binding variable or condition

Mario Fusco (JIRA) issues at jboss.org
Fri Aug 28 05:41:05 EDT 2015


    [ https://issues.jboss.org/browse/DROOLS-897?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13103035#comment-13103035 ] 

Mario Fusco edited comment on DROOLS-897 at 8/28/15 5:40 AM:
-------------------------------------------------------------

Sorry, but I think you're not understanding what I'm saying. Let me rephrase. At COMPILE TIME we generate a syntetic Java method implementing the consequence's body. In your case it should be something like this:

{code}
public void doConsequence(Drools drools, X $entity, java.util.Map $t, java.math.BigDecimal $cambio) {
    $entity.setCodDiviCont($t.get("cod_divi_contab").toString());
    $entity.setCambioDiviCont($cambio);
    drools.update( $entity );
}
{code}

Of which type should be X in your case to make that method to work for all possible types of $entity?


was (Author: mfusco):
Sorry, but I think you're not understanding what I'm saying. Let me rephrase. At COMPILE TIME we generate a syntetic Java method implementing the consequence's body. In your case it should be something like this:

{code}
public void doConsequence(Drools drools, X $entity) {
    $entity.setCodDiviCont($t.get("cod_divi_contab").toString());
    $entity.setCambioDiviCont($cambio);
    drools.update( $entity );
}
{code}

Of which type should be X in your case to make that method to work for all possible types of $entity?

> Binding variable or condition
> -----------------------------
>
>                 Key: DROOLS-897
>                 URL: https://issues.jboss.org/browse/DROOLS-897
>             Project: Drools
>          Issue Type: Bug
>          Components: core engine
>    Affects Versions: 6.2.0.Final
>         Environment: Windows 8
>            Reporter: Sante Stanisci
>            Assignee: Mario Fusco
>              Labels: dynamic, instanciation, variable
>         Attachments: rule.drl, workaround.drl
>
>
> In this example I have more classes that extends EntityBase (my class). In my intention, i would assign to variable $entity one of this class that is inserted in Ksession fact.
> I insert fact of CtbMovrCoan class
> In when statement of the rule at row 16, variable $entity is correctely, 
> but in then statement variable $entity becomes JtbRLavt class (first declared in then cond) and this behavior throw a ClassCastException, obviously.
> Can Help me?



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


More information about the jboss-jira mailing list