Ich verwende Feder, um Batch-Datensätze in die DB einzufügen. Aber ich bekomme diesen Fehler: java.sql.SQLException: Konnte nicht zwischen java.util.ArrayList und JAVA_OBJECT konvertieren. können Sie bitte helfen Sie, was ich falschsprint benannteParameterJdbcTemplate batchUpdate mit in Klausel
private static final String INSERT_BATCH_QUERY ="INSERT INTO TEST_TABLE (ID,TEST_ID) select :id, substring((SELECT ', ' + USERS.COMMON_NAME FROM USERS WHERE USERS.ID IN (:testIds) FOR XML PATH('')), 2, 4000);
public class Test{
private int id;
private List<Intenger> testIds;
//**getters and setters**//
}
public static void Main(String... args){
List<Test> myTe=new ....
SqlParameterSource[] sqlParameterSource = SqlParameterSourceUtils.createBatch(myTe.toArray());
result = namedParameterJdbcTemplate.batchUpdate(INSERT_BATCH_QUERY, sqlParameterSource);
}
Fehler machen:
Caused by: java.sql.SQLException: Unable to convert between java.util.ArrayList and JAVA_OBJECT.
at net.sourceforge.jtds.jdbc.Support.convert(Support.java:633)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setObjectBase(JtdsPreparedStatement.java:590)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setObject(JtdsPreparedStatement.java:907)
at com.jolbox.bonecp.PreparedStatementHandle.setObject(PreparedStatementHandle.java:909)
at org.springframework.jdbc.core.StatementCreatorUtils.setValue(StatementCreatorUtils.java:426)
at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:235)
at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:166)
at org.springframework.jdbc.core.BatchUpdateUtils.setStatementParameters(BatchUpdateUtils.java:65)
at org.springframework.jdbc.core.namedparam.NamedParameterBatchUpdateUtils.access$000(NamedParameterBatchUpdateUtils.java:32)
at org.springframework.jdbc.core.namedparam.NamedParameterBatchUpdateUtils$1.setValues(NamedParameterBatchUpdateUtils.java:48)
at org.springframework.jdbc.core.JdbcTemplate$4.doInPreparedStatement(JdbcTemplate.java:1010)
at org.springframework.jdbc.core.JdbcTemplate$4.doInPreparedStatement(JdbcTemplate.java:989)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:644)
... 26 more
Wenn ich hartcodierte Werte:
private static final String INSERT_BATCH_QUERY ="INSERT INTO TEST_TABLE (ID,TEST_ID) select :id, substring((SELECT ', ' + USERS.COMMON_NAME FROM USERS WHERE USERS.ID IN (1234,654,55) FOR XML PATH('')), 2, 4000);
oder wenn ich pass nur ein int es funktioniert .
Bitte helfen :)