[ https://issues.apache.org/jira/browse/CAY-2470?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Nikita Timofeev closed CAY-2470. -------------------------------- Resolution: Fixed *4.1*: https://github.com/apache/cayenne/commit/8047c588442692992c752bdf5ad5710f32eb18b7 *4.0*: https://github.com/apache/cayenne/commit/9495e30b1b3502f710019b36e683be3ab873b3ad > 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.1.M2, 4.0 > Reporter: Andrus Adamchik > Assignee: Nikita Timofeev > Priority: Minor > Fix For: 4.0.1, 4.1.M3 > > > 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)