5 Replies Latest reply: Dec 7, 2012 5:21 AM by Tiago Braz RSS

    Passivate issue while applying viewCriteria on runtime

    Tiago Braz

      (ADF BC on jDev

      Hoping someone can shed some light on this. (the issue is not how to do this, but why doing it like this is not working)

      Here goes :

      Supose, you need to list all employees from departmant 60 (considering HR schema) while at the same time, i need to know wich one of them has a sallary > some_value.
      (Again, i'm sure there are lots of ways to do this, but the issue is not how to do it, but why doing it like this raises some passivation issues.)

      So, i created the Department and Employee viewObjects (linked together). And created a viewCriteria for salary > vc_salary inside EmplyeeView.

      Now on the view, consider the approach: I created the following, simple, action method:
          public void apply1VC(ActionEvent actionEvent) {
             // will set the current row of departments so i the depat 60 employees.
              // for some reason, i need to know how many employess there are with a salary > 5000, belonging top department 60.
              // So, ill apply a view criteria, do my business logic, and then remove it:
              //apply vc
              ViewObject viewObject = ADFUtils.findIterator("EmployeesViewIterator").getViewObject();
              ViewCriteriaManager vcm = viewObject.getViewCriteriaManager();
              ViewCriteria vc = vcm.getViewCriteria("bySalary");
              VariableValueManager vm = vc.ensureVariableManager();
              vm.setVariableValue("vc_salary", new BigDecimal(5000));
              //execute query
              //do the business logic here to the employees with salary > 5000
              //remove the viewcriteria
              // force executeQuery on my terms to list all employees of dept 50
      This executes perfectly and does its job as expected. But! If after this method is executed, a passivate/activate occurs,the application will blow up on the next activation (easely checked with AM pooling turned off):

      java.sql.SQLException: Missing IN or OUT parameter at index:: 1
      <MethodExpressionActionListener> <processAction> oracle.jbo.SQLStmtException: JBO-27122: Erro de SQL durante a preparação da instrução. Instrução: SELECT Employees.EMPLOYEE_ID, Employees.FIRST_NAME, Employees.LAST_NAME, Employees.EMAIL, Employees.PHONE_NUMBER, Employees.HIRE_DATE, Employees.JOB_ID, Employees.SALARY, Employees.COMMISSION_PCT, Employees.MANAGER_ID, Employees.DEPARTMENT_ID FROM EMPLOYEES Employees WHERE ( ( (Employees.SALARY > :vc_salary ) ) ) AND Employees.DEPARTMENT_ID = :Bind_DepartmentId

      Like as if the view object is beeing passivate with the viewCriteria still applied and while activating trys to insert a parameter that already does not exist.

      Am i missing something? Is there any reason for this implementation to raise such a problem?

      If any of you kind souls is interested enough, here is the application i did to reproduce this issue. (you just have to do 3 clicks and the only code inside is the one on the post):

      Thank you!
      Tiago Braz

      Edited by: Tiago Braz on 5/Dez/2012 11:09