Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-2470

Can't bind SQLExec parameters in a loop

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 4.0, 4.1.M2
    • Fix Version/s: 4.0.1, 4.1.B1
    • Component/s: Core Library
    • Labels:
      None

      Description

      I am trying to use SQLExec for batch inserts, reusing the basic query:

      SQLExec inserter = SQLExec.query("insert into t1 (id) values (#bind($id))");
      for(int i = 0; i < 2; i++) {
         inserter.paramsArray(i).execute(context);
      }

      This works on the first loop iteration, but fails on the second with a duplicate PK error. Looks like the underlying "replacementQuery" is compiled only once during the first "execute()" call and is cached on subsequent calls even though the main query settings have changed.

      I suspect this issue affects other subclasses of IndirectQuery as well... We need to clear their cached state if the settings affecting it change in the main query.

       

        Attachments

          Activity

            People

            • Assignee:
              ntimofeev Nikita Timofeev
              Reporter:
              andrus Andrus Adamchik
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: