Search in sources :

Example 1 with Wordbook

use of zjp.translateit.domain.Wordbook in project TranslateIt-api by zunpiau.

the class WordbookRepositoryImpl method save.

@Override
public int save(long uid, List<Wordbook> wordbooks) {
    return template.batchUpdate("INSERT INTO wordbook ( uid, " + WORDBOOK_FILED + " ) VALUES(?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() {

        @Override
        public void setValues(PreparedStatement ps, int i) throws SQLException {
            Wordbook wordbook = wordbooks.get(i);
            ps.setLong(1, uid);
            ps.setString(2, wordbook.getWord());
            ps.setString(3, wordbook.getPhEn());
            ps.setString(4, wordbook.getPhAm());
            ps.setString(5, wordbook.getPhEnUrl());
            ps.setString(6, wordbook.getPhAmUrl());
            ps.setString(7, wordbook.getMean());
            ps.setString(8, wordbook.getExchange());
            ps.setString(9, wordbook.getSentence());
            ps.setString(10, wordbook.getNote());
            ps.setString(11, wordbook.getCategory());
        }

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

Aggregations

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