Package org.springframework.jdbc.object

Examples of org.springframework.jdbc.object.BatchSqlUpdate


    jdbcTemplate.execute("truncate music.albuminfo_import");
  }
 
  private void batchInsert(List<AlbumInfo> albumInfos) {
    String sql = "insert into music.albuminfo_import (artist_name, album_name, smallimageurl, mediumimageurl, largeimageurl, extraLargeimageurl, listeners, playcount) values (?,?,?,?,?,?,?,?)";
    BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
    batchUpdate.setBatchSize(1000);
    batchUpdate.declareParameter(new SqlParameter("artist_name", Types.VARCHAR));
    batchUpdate.declareParameter(new SqlParameter("album_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));
   
    for (AlbumInfo ai : albumInfos) {
      batchUpdate.update(new Object[]{ai.getAlbum().getArtist().getName(), ai.getAlbum().getName(),
          ai.getSmallImageUrl(), ai.getMediumImageUrl(), ai.getLargeImageUrl(),
          ai.getExtraLargeImageUrl(), ai.getListeners(), ai.getPlayCount()});
    }
    batchUpdate.flush();
  }
View Full Code Here


    jdbcTemplate.execute("truncate library.trackplaycount_import");
  }
 
  private void batchInsert(List<TrackPlayCount> trackPlayCounts) {
    String sql = "insert into library.trackplaycount_import (artist_name, track_name, play_count) values (?,?,?)";
    BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
    batchUpdate.setBatchSize(1000);
    batchUpdate.declareParameter(new SqlParameter("artist_name", Types.VARCHAR));
    batchUpdate.declareParameter(new SqlParameter("track_name", Types.VARCHAR));
    batchUpdate.declareParameter(new SqlParameter("play_count", Types.INTEGER));
   
    for (TrackPlayCount tpc : trackPlayCounts) {
      batchUpdate.update(new Object[]{tpc.getTrack().getArtist().getName(),
          tpc.getTrack().getName(), tpc.getPlayCount()});
    }
    batchUpdate.flush();
  }
View Full Code Here

  private void batchInsert(Artist artist, List<Track> topTracks) {
    int sourceArtistId = jdbcTemplate.queryForInt(
        "select * from music.get_artist_id(?)", artist.getName());
   
    String sql = "insert into music.artisttoptrack_import (artist_id, track_name, rank) values (?,?,?)";
    BatchSqlUpdate batchUpdate = new BatchSqlUpdate(jdbcTemplate.getDataSource(), sql);
    batchUpdate.setBatchSize(1000);
    batchUpdate.declareParameter(new SqlParameter("artist_id", Types.INTEGER));
    batchUpdate.declareParameter(new SqlParameter("track_name", Types.VARCHAR));
    batchUpdate.declareParameter(new SqlParameter("rank", Types.SMALLINT));
   
    short rank = 0;
    for (Track t : topTracks) {
      batchUpdate.update(new Object[]{sourceArtistId, t.getName(), ++rank});
    }
    batchUpdate.flush();
  }
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.object.BatchSqlUpdate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.