use of org.springframework.jdbc.core.SqlParameter 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.core.SqlParameter 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();
}
use of org.springframework.jdbc.core.SqlParameter 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.core.SqlParameter 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.core.SqlParameter 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()");
}
Aggregations