use of org.springframework.jdbc.object.BatchSqlUpdate in project musiccabinet by hakko.
the class JdbcArtistInfoDao method batchInsert.
private void batchInsert(List<ArtistInfo> artistInfos) {
String sql = "insert into music.artistinfo_import (artist_name, smallimageurl, mediumimageurl, largeimageurl, extralargeimageurl, listeners, playcount, biosummary, biocontent) values (?,?,?,?,?,?,?,?,?)";
BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
batchUpdate.setBatchSize(1000);
batchUpdate.declareParameter(new SqlParameter("artist_name", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("smallImageUrl", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("mediumImageUrl", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("largeImageUrl", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("extraLargeImageUrl", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("listeners", Types.INTEGER));
batchUpdate.declareParameter(new SqlParameter("playcount", Types.INTEGER));
batchUpdate.declareParameter(new SqlParameter("biosummary", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("biocontent", Types.VARCHAR));
for (ArtistInfo ai : artistInfos) {
batchUpdate.update(new Object[] { ai.getArtist().getName(), ai.getSmallImageUrl(), ai.getMediumImageUrl(), ai.getLargeImageUrl(), ai.getExtraLargeImageUrl(), ai.getListeners(), ai.getPlayCount(), ai.getBioSummary(), ai.getBioContent() });
}
batchUpdate.flush();
}
use of org.springframework.jdbc.object.BatchSqlUpdate in project musiccabinet by hakko.
the class JdbcArtistRelationDao method batchInsert.
private void batchInsert(Artist sourceArtist, List<ArtistRelation> ArtistRelations) {
int sourceArtistId = jdbcTemplate.queryForInt("select * from music.get_artist_id(?)", sourceArtist.getName());
String sql = "insert into music.artistrelation_import (source_id, target_artist_name, weight) values (?,?,?)";
BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
batchUpdate.setBatchSize(1000);
batchUpdate.declareParameter(new SqlParameter("source_id", Types.INTEGER));
batchUpdate.declareParameter(new SqlParameter("target_artist_name", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("weight", Types.FLOAT));
for (ArtistRelation ar : ArtistRelations) {
batchUpdate.update(new Object[] { sourceArtistId, ar.getTarget().getName(), ar.getMatch() });
}
batchUpdate.flush();
}
use of org.springframework.jdbc.object.BatchSqlUpdate in project musiccabinet by hakko.
the class JdbcArtistTopTagsDao method batchInsert.
private void batchInsert(Artist artist, List<Tag> tags) {
int sourceArtistId = jdbcTemplate.queryForInt("select * from music.get_artist_id(?)", artist.getName());
String sql = "insert into music.artisttoptag_import (artist_id, tag_name, tag_count) values (?,?,?)";
BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
batchUpdate.setBatchSize(1000);
batchUpdate.declareParameter(new SqlParameter("artist_id", Types.INTEGER));
batchUpdate.declareParameter(new SqlParameter("tag_name", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("tag_count", Types.SMALLINT));
for (Tag tag : tags) {
batchUpdate.update(new Object[] { sourceArtistId, tag.getName(), tag.getCount() });
}
batchUpdate.flush();
}
Aggregations