Search in sources :

Example 1 with ModifyWordbook

use of zjp.translateit.dto.ModifyWordbook in project TranslateIt-api by zunpiau.

the class WordbookRepositoryImpl method update.

public int update(long uid, List<ModifyWordbook> wordbooks) {
    return template.batchUpdate("UPDATE wordbook SET note = ?, category = ? WHERE uid = ? AND word = ? ", new BatchPreparedStatementSetter() {

        @Override
        public void setValues(PreparedStatement ps, int i) throws SQLException {
            ModifyWordbook wordbook = wordbooks.get(i);
            ps.setString(1, wordbook.getNote());
            ps.setString(2, wordbook.getCategory());
            ps.setLong(3, uid);
            ps.setString(4, wordbook.getWord());
        }

        @Override
        public int getBatchSize() {
            return wordbooks.size();
        }
    }).length;
}
Also used : BatchPreparedStatementSetter(org.springframework.jdbc.core.BatchPreparedStatementSetter) ModifyWordbook(zjp.translateit.dto.ModifyWordbook) PreparedStatement(java.sql.PreparedStatement)

Aggregations

PreparedStatement (java.sql.PreparedStatement)1 BatchPreparedStatementSetter (org.springframework.jdbc.core.BatchPreparedStatementSetter)1 ModifyWordbook (zjp.translateit.dto.ModifyWordbook)1