Uploaded image for project: 'Red Hat Decision Manager'
  1. Red Hat Decision Manager
  2. RHDM-2016

EXISTS and NOT don't work correctly with multiple constraints with BigDecimal

    XMLWordPrintable

Details

    • False
    • None
    • False
    • Hide
      $ unzip reproducer_exists_not_1d.zip
      $ cd reproducer_exists_not_1d
      $ ./run_mvn 
      === generateModel=NO ===
          :
          :
      ***** start
      ***** Rule 1: $definition=com.example.reproducer.Definition@39fc6b2c{value1=1234, value2=567}
      ***** Rule 1: $definition=com.example.reproducer.Definition@6c44052e{value1=9999, value2=567}    <---------- Rule 2 should be fired for this Definition object
      ***** Rule 2: $definition=com.example.reproducer.Definition@530a8454{value1=1234, value2=999}
      ***** Rule 2: $definition=com.example.reproducer.Definition@5215cd9a{value1=9999, value2=999}
      ***** end
          :
          :
      
      === generateModel=YES ===
          :
          :
      ***** start
      ***** Rule 1: $definition=com.example.reproducer.Definition@76c7beb3{value1=1234, value2=567}
      ***** Rule 1: $definition=com.example.reproducer.Definition@4b85880b{value1=9999, value2=567}    <---------- Rule 2 should be fired for this Definition object
      ***** Rule 2: $definition=com.example.reproducer.Definition@4215838f{value1=1234, value2=999}
      ***** Rule 2: $definition=com.example.reproducer.Definition@2289aca5{value1=9999, value2=999}
      ***** end
          :
          :
      

      Expected behavior - "Rule 2" should be fired at the lines for the Definition{value1="9999", value2="567"} object above.
      Actual behavior - "Rule 1" is fired at the lines.

      Show
      $ unzip reproducer_exists_not_1d.zip $ cd reproducer_exists_not_1d $ ./run_mvn === generateModel=NO === : : ***** start ***** Rule 1: $definition=com.example.reproducer.Definition@39fc6b2c{value1=1234, value2=567} ***** Rule 1: $definition=com.example.reproducer.Definition@6c44052e{value1=9999, value2=567} <---------- Rule 2 should be fired for this Definition object ***** Rule 2: $definition=com.example.reproducer.Definition@530a8454{value1=1234, value2=999} ***** Rule 2: $definition=com.example.reproducer.Definition@5215cd9a{value1=9999, value2=999} ***** end : : === generateModel=YES === : : ***** start ***** Rule 1: $definition=com.example.reproducer.Definition@76c7beb3{value1=1234, value2=567} ***** Rule 1: $definition=com.example.reproducer.Definition@4b85880b{value1=9999, value2=567} <---------- Rule 2 should be fired for this Definition object ***** Rule 2: $definition=com.example.reproducer.Definition@4215838f{value1=1234, value2=999} ***** Rule 2: $definition=com.example.reproducer.Definition@2289aca5{value1=9999, value2=999} ***** end : : Expected behavior - "Rule 2" should be fired at the lines for the Definition{value1="9999", value2="567" } object above. Actual behavior - "Rule 1" is fired at the lines.
    • 2023 Week 36-38 (from Sep 4)

    Description

      With the rule

      package com.example.reproducer;
      
      dialect "mvel"
      
      rule "Rule 1"
          when
              $definition : Definition( $value1 : value1, $value2 : value2 )
              exists Fact( $value1 == value1, $value2 == value2 )
          then
              System.out.println("***** " + drools.getRule().getName() + ": $definition=" + $definition);
      end
      
      rule "Rule 2"
          when
              $definition : Definition( $value1 : value1, $value2 : value2 )
              not Fact( $value1 == value1, $value2 == value2 )
          then
              System.out.println("***** " + drools.getRule().getName() + ": $definition=" + $definition);
      end
      

      inserting objects like:

                  Definition def2 = new Definition();
                  def2.setValue1("9999");
                  def2.setValue2("567");
                  kSession.insert(def2);
      
                  Fact fact2 = new Fact();
                  fact2.setValue1(new BigDecimal("9009"));
                  fact2.setValue2(new BigDecimal("567"));
                  kSession.insert(fact2);
      

      fires "Rule 1" (instead of "Rule 2") although def2.value1 and fact2.value1 are different.

      Note that Definition.value1 and value2 are both String. Fact.value1 and value2 are both BigDecimal.

      This happens in both exec-model and non-exec-model

      Attachments

        Activity

          People

            rhn-support-tkobayas Toshiya Kobayashi
            rhn-support-myoshida Masato Yoshida
            Paolo Bizzarri Paolo Bizzarri
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: