Details
- 
    Bug 
- 
    Status: Closed (View Workflow)
- 
    Major 
- 
    Resolution: Fixed
- 
    2.1.2
- 
    None
Description
When we adding batched query in form of:
insert ...  values (:some_id, (SELECT X from other_table where fk = :some_id))
It seems that result of sub-query somewhere caches, and produces invalid data.
Here's test excerpt which also failing:
    @Test
    public void testNonCachingBatchUpdate() throws SQLException {
        createTable("testNonCachingBatchUpdate1", "col int, val int");
        createTable("testNonCachingBatchUpdate2", "col int, val int");
        Statement statement = sharedConnection.createStatement();
        //add 100 data
        StringBuilder sb = new StringBuilder("INSERT INTO testNonCachingBatchUpdate1(col, val) VALUES (0,0), (1,1)");
        statement.execute(sb.toString());
        try (PreparedStatement preparedStatement = sharedConnection.prepareStatement(
                "INSERT INTO testNonCachingBatchUpdate2(col, val) VALUES (?, " +
                        "(SELECT val FROM testNonCachingBatchUpdate1 where col = ?))")) 
        //check results
        try (ResultSet rs = statement.executeQuery("SELECT * FROM testNonCachingBatchUpdate2 order by col")) 
}