[ 
https://issues.apache.org/jira/browse/CAY-2470?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andrus Adamchik updated CAY-2470:
---------------------------------
    Description: 
I am trying to use SQLExec for batch inserts, reusing the basic query:
{noformat}
SQLExec inserter = SQLExec.query("insert into t1 (id) values (#bind($id))");
for(int i = 0; i < 2; i++) {
   inserter.paramsArray(i).execute(context);
}{noformat}
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.

 

  was:
I am trying to use SQLExec for batch inserts, reusing the basic query:
{noformat}
SQLExec inserter = SQLExec.query("insert into t1 (id) values (#bind($id))");
for(int i = 0; i < 2; i++) {
   inserter.paramsArray(i).execute(context);
}{noformat}
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... We need to 
clear their cached state if the settings affecting it change in the main query.

 


> Can't bind SQLExec parameters in a loop
> ---------------------------------------
>
>                 Key: CAY-2470
>                 URL: https://issues.apache.org/jira/browse/CAY-2470
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 4.0
>            Reporter: Andrus Adamchik
>            Assignee: Nikita Timofeev
>            Priority: Minor
>
> I am trying to use SQLExec for batch inserts, reusing the basic query:
> {noformat}
> SQLExec inserter = SQLExec.query("insert into t1 (id) values (#bind($id))");
> for(int i = 0; i < 2; i++) {
>    inserter.paramsArray(i).execute(context);
> }{noformat}
> 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.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to