My xml
<code><update id="truncateTable">
truncate TABLE ${tableName}
</update>
</code>
<code><update id="truncateTable">
truncate TABLE ${tableName}
</update>
</code>
<update id="truncateTable">
truncate TABLE ${tableName}
</update>
<code> public void flushNeoReceivePayment() throws IOException {
dwsTableSqlMapper.truncateTable("dwd_table");
dwsTableSqlMapper.insertSomething1();
dwsTableSqlMapper.insertSomething1();
}
</code>
<code> public void flushNeoReceivePayment() throws IOException {
dwsTableSqlMapper.truncateTable("dwd_table");
dwsTableSqlMapper.insertSomething1();
dwsTableSqlMapper.insertSomething1();
}
</code>
public void flushNeoReceivePayment() throws IOException {
dwsTableSqlMapper.truncateTable("dwd_table");
dwsTableSqlMapper.insertSomething1();
dwsTableSqlMapper.insertSomething1();
}
The insertSomething1 method inserts a portion of data
It is normal after the first execution, but an error occurs when the second execution starts
<code>Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5368e1af] was not registered for synchronization because synchronization is not active
JDBC Connection [HikariProxyConnection@1571751346 wrapping com.mysql.cj.jdbc.ConnectionImpl@72168258] will not be managed by Spring
==> Preparing: truncate dwd_table
==> Parameters:
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5368e1af]
2024-09-10 13:32:27.685 ERROR --- [nio-3009-exec-2] c.z.z.c.exceptions.GlobalExceptionHandle :
org.springframework.dao.TransientDataAccessResourceException:
### Error updating database. Cause: java.sql.SQLException: Index 0 out of bounds for length 0
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: truncate dwd_table
### Cause: java.sql.SQLException: Index 0 out of bounds for length 0
; Index 0 out of bounds for length 0; nested exception is java.sql.SQLException: Index 0 out of bounds for length 0
</code>
<code>Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5368e1af] was not registered for synchronization because synchronization is not active
JDBC Connection [HikariProxyConnection@1571751346 wrapping com.mysql.cj.jdbc.ConnectionImpl@72168258] will not be managed by Spring
==> Preparing: truncate dwd_table
==> Parameters:
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5368e1af]
2024-09-10 13:32:27.685 ERROR --- [nio-3009-exec-2] c.z.z.c.exceptions.GlobalExceptionHandle :
org.springframework.dao.TransientDataAccessResourceException:
### Error updating database. Cause: java.sql.SQLException: Index 0 out of bounds for length 0
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: truncate dwd_table
### Cause: java.sql.SQLException: Index 0 out of bounds for length 0
; Index 0 out of bounds for length 0; nested exception is java.sql.SQLException: Index 0 out of bounds for length 0
</code>
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5368e1af] was not registered for synchronization because synchronization is not active
JDBC Connection [HikariProxyConnection@1571751346 wrapping com.mysql.cj.jdbc.ConnectionImpl@72168258] will not be managed by Spring
==> Preparing: truncate dwd_table
==> Parameters:
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5368e1af]
2024-09-10 13:32:27.685 ERROR --- [nio-3009-exec-2] c.z.z.c.exceptions.GlobalExceptionHandle :
org.springframework.dao.TransientDataAccessResourceException:
### Error updating database. Cause: java.sql.SQLException: Index 0 out of bounds for length 0
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: truncate dwd_table
### Cause: java.sql.SQLException: Index 0 out of bounds for length 0
; Index 0 out of bounds for length 0; nested exception is java.sql.SQLException: Index 0 out of bounds for length 0
Strangely, the first call to this method was normal, but the second call resulted in an error. Upon checking the logs, it was found that the sqlsession was successfully created, but an error similar to a failed parameter pass occurred
What’s even stranger is that if my insertSomething1 method is called only once, or if I replace truncate with delete, there won’t be any issues
<code>public void flushNeoReceivePayment() throws IOException {
dwsTableSqlMapper.truncateTable("dwd_table");
dwsTableSqlMapper.insertSomething1();
} OK.
</code>
<code>public void flushNeoReceivePayment() throws IOException {
dwsTableSqlMapper.truncateTable("dwd_table");
dwsTableSqlMapper.insertSomething1();
} OK.
</code>
public void flushNeoReceivePayment() throws IOException {
dwsTableSqlMapper.truncateTable("dwd_table");
dwsTableSqlMapper.insertSomething1();
} OK.
2