Hi all,
 
I have doubt regarding the following rules:
 

rule

"A Rule"

  when

       not LoanBean();

   then

      LoanBean loan =

new LoanBean();

      loan.setLoanId(

"1");

      System.out.println(

"A rule");

      loan.setLoanId(

"1");

       assertLogical(loan);

end

 

rule

"B Rule"

    when

         a:LoanBean(loanId ==

"1");

     then

         System.out.println(

"B Rule");

end

 

In the above examples, if I am using assert(loan), then it is printing as "A Rule" and "B Rule". But when I have used assertLogical(loan), then "A Rule" is printing continously, without "B Rule" printing. Why?

 

And also I am able to use Global variable for loan(LoanBean loan). I have setGlobal in the workingMemory.  The same thing If I used like below using global, I am getting the NullPointer Exception. I have set

 

global LoanBean loan;

rule "A Rule"

  when

       not LoanBean();

   then

      loan =

new LoanBean();

      loan.setLoanId(

"1"); // Why In IDE, setLoanId() is not coming if the loan is the global, but if it's

                                          local like LoanBean loan = new LoanBean(), then all the properties are   

                                           displaying   

      System.out.println(

"A rule");

      loan.setLoanId(

"1");

      assertLogical(loan);

end

 

rule

"B Rule"

    when

         a:LoanBean(loanId ==

"1");

     then

         System.out.println(

"B Rule");

end

 

Regards,

Micheal john


 

Get email for your site ---> http://www.everyone.net