use of org.springframework.jdbc.object.BatchSqlUpdate in project musiccabinet by hakko.
the class JdbcLibraryDeletionDao method deleteSubdirectories.
@Override
public void deleteSubdirectories(String directory, Set<String> subDirectories) {
String sql = "insert into library.directory_delete (path) values (?)";
BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
batchUpdate.declareParameter(new SqlParameter("path", Types.VARCHAR));
for (String subDirectory : subDirectories) {
batchUpdate.update(new Object[] { subDirectory });
}
batchUpdate.flush();
}
use of org.springframework.jdbc.object.BatchSqlUpdate in project musiccabinet by hakko.
the class JdbcMusicBrainzArtistDao method batchInsert.
private void batchInsert(List<MBArtist> artists) {
String sql = "insert into music.mb_artist_import (artist_name, mbid, country_code, start_year, active) values (?,?,?,?,?)";
BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
batchUpdate.setBatchSize(1000);
batchUpdate.declareParameter(new SqlParameter("artist_name", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("mbid", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("county_code", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("start_year", Types.SMALLINT));
batchUpdate.declareParameter(new SqlParameter("active", Types.BOOLEAN));
for (MBArtist artist : artists) {
batchUpdate.update(new Object[] { artist.getName(), artist.getMbid(), artist.getCountryCode(), artist.getStartYear(), artist.isActive() });
}
batchUpdate.flush();
}
use of org.springframework.jdbc.object.BatchSqlUpdate in project musiccabinet by hakko.
the class JdbcTagInfoDao method createTagInfo.
@Override
public void createTagInfo(List<TagInfo> tagInfos) {
String sql = "insert into music.taginfo_import (tag_name, summary, content) values (?,?,?)";
BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
batchUpdate.setBatchSize(1000);
batchUpdate.declareParameter(new SqlParameter("tag_name", VARCHAR));
batchUpdate.declareParameter(new SqlParameter("summary", VARCHAR));
batchUpdate.declareParameter(new SqlParameter("content", VARCHAR));
for (TagInfo ti : tagInfos) {
batchUpdate.update(new Object[] { ti.getTagName(), ti.getSummary(), ti.getContent() });
}
batchUpdate.flush();
jdbcTemplate.execute("select music.update_taginfo()");
}
use of org.springframework.jdbc.object.BatchSqlUpdate in project musiccabinet by hakko.
the class JdbcUserLovedTracksDao method batchInsert.
private void batchInsert(String lastFmUsername, List<Track> lovedTracks) {
String sql = "insert into music.lovedtrack_import" + " (lastfm_user, artist_name, track_name) values (?,?,?)";
BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
batchUpdate.setBatchSize(1000);
batchUpdate.declareParameter(new SqlParameter("lastfm_user", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("artist_name", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("track_name", Types.VARCHAR));
for (Track track : lovedTracks) {
batchUpdate.update(new Object[] { lastFmUsername, track.getArtist().getName(), track.getName() });
}
batchUpdate.flush();
}
use of org.springframework.jdbc.object.BatchSqlUpdate in project musiccabinet by hakko.
the class JdbcUserRecommendedArtistsDao method batchInsert.
private void batchInsert(List<RecommendedArtist> artists, LastFmUser user) {
String sql = "insert into music.userrecommendedartist_import" + " (lastfm_user, artist_name, rank, contextartist1_name, contextartist2_name)" + " values (?,?,?,?,?)";
BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
batchUpdate.setBatchSize(1000);
batchUpdate.declareParameter(new SqlParameter("lastfm_user", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("artist_name", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("rank", Types.INTEGER));
batchUpdate.declareParameter(new SqlParameter("contextartist1_name", Types.VARCHAR));
batchUpdate.declareParameter(new SqlParameter("contextartist2_name", Types.VARCHAR));
for (int i = 0; i < artists.size(); i++) {
RecommendedArtist rec = artists.get(i);
batchUpdate.update(new Object[] { user.getLastFmUsername(), rec.getArtist().getName(), i, name(rec.getContextArtist1()), name(rec.getContextArtist2()) });
}
batchUpdate.flush();
}
Aggregations