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

Can't bind SQLExec parameters in a loop

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 4.0, 4.1.M2
    • 4.0.1, 4.1.B1
    • Core Library
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: