Search in sources :

Example 1 with ArtistPlayCount

use of com.github.hakko.musiccabinet.domain.model.music.ArtistPlayCount in project musiccabinet by hakko.

the class JdbcGroupWeeklyArtistChartDao method batchInsert.

private void batchInsert(GroupWeeklyArtistChart artistChart) {
    String sql = "insert into music.groupweeklyartistchart_import (lastfmgroup_name, artist_name, playcount) values (?,?,?)";
    BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
    batchUpdate.setBatchSize(1000);
    batchUpdate.declareParameter(new SqlParameter("lastfmgroup_name", Types.VARCHAR));
    batchUpdate.declareParameter(new SqlParameter("artist_name", Types.VARCHAR));
    batchUpdate.declareParameter(new SqlParameter("playcount", Types.INTEGER));
    for (ArtistPlayCount apc : artistChart.getArtistPlayCounts()) {
        batchUpdate.update(new Object[] { artistChart.getGroupName(), apc.getArtist().getName(), apc.getPlayCount() });
    }
    batchUpdate.flush();
}
Also used : ArtistPlayCount(com.github.hakko.musiccabinet.domain.model.music.ArtistPlayCount) SqlParameter(org.springframework.jdbc.core.SqlParameter) BatchSqlUpdate(org.springframework.jdbc.object.BatchSqlUpdate)

Aggregations

ArtistPlayCount (com.github.hakko.musiccabinet.domain.model.music.ArtistPlayCount)1 SqlParameter (org.springframework.jdbc.core.SqlParameter)1 BatchSqlUpdate (org.springframework.jdbc.object.BatchSqlUpdate)1