Update dao layer to use update spring-jdbc 3/4 api

Signed-off-by: Andrew DeMaria <lostonamountain@gmail.com>
master
Andrew DeMaria 9 years ago
parent 53dc138574
commit 3213b3f115
  1. 3
      libresonic-main/src/main/java/org/libresonic/player/dao/AlbumDao.java
  2. 3
      libresonic-main/src/main/java/org/libresonic/player/dao/ArtistDao.java
  3. 6
      libresonic-main/src/main/java/org/libresonic/player/dao/AvatarDao.java
  4. 6
      libresonic-main/src/main/java/org/libresonic/player/dao/BookmarkDao.java
  5. 6
      libresonic-main/src/main/java/org/libresonic/player/dao/InternetRadioDao.java
  6. 23
      libresonic-main/src/main/java/org/libresonic/player/dao/MediaFileDao.java
  7. 11
      libresonic-main/src/main/java/org/libresonic/player/dao/MusicFolderDao.java
  8. 3
      libresonic-main/src/main/java/org/libresonic/player/dao/PlayQueueDao.java
  9. 23
      libresonic-main/src/main/java/org/libresonic/player/dao/PlayerDao.java
  10. 3
      libresonic-main/src/main/java/org/libresonic/player/dao/PlaylistDao.java
  11. 5
      libresonic-main/src/main/java/org/libresonic/player/dao/PodcastDao.java
  12. 8
      libresonic-main/src/main/java/org/libresonic/player/dao/ShareDao.java
  13. 6
      libresonic-main/src/main/java/org/libresonic/player/dao/TranscodingDao.java
  14. 19
      libresonic-main/src/main/java/org/libresonic/player/dao/UserDao.java

@ -29,7 +29,6 @@ import java.util.Map;
import org.apache.commons.lang.ObjectUtils;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.libresonic.player.domain.Album;
import org.libresonic.player.domain.MediaFile;
@ -346,7 +345,7 @@ public class AlbumDao extends AbstractDao {
return queryForDate("select created from starred_album where album_id=? and username=?", null, albumId, username);
}
private static class AlbumMapper implements ParameterizedRowMapper<Album> {
private static class AlbumMapper implements RowMapper<Album> {
public Album mapRow(ResultSet rs, int rowNum) throws SQLException {
return new Album(
rs.getInt(1),

@ -24,7 +24,6 @@ import org.libresonic.player.domain.Artist;
import org.libresonic.player.domain.MusicFolder;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -199,7 +198,7 @@ public class ArtistDao extends AbstractDao {
return queryForDate("select created from starred_artist where artist_id=? and username=?", null, artistId, username);
}
private static class ArtistMapper implements ParameterizedRowMapper<Artist> {
private static class ArtistMapper implements RowMapper<Artist> {
public Artist mapRow(ResultSet rs, int rowNum) throws SQLException {
return new Artist(
rs.getInt(1),

@ -20,7 +20,7 @@
package org.libresonic.player.dao;
import org.libresonic.player.domain.Avatar;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -85,11 +85,11 @@ public class AvatarDao extends AbstractDao {
}
}
private static class AvatarRowMapper implements ParameterizedRowMapper<Avatar> {
private static class AvatarRowMapper implements RowMapper<Avatar> {
public Avatar mapRow(ResultSet rs, int rowNum) throws SQLException {
return new Avatar(rs.getInt(1), rs.getString(2), rs.getTimestamp(3), rs.getString(4),
rs.getInt(5), rs.getInt(6), rs.getBytes(7));
}
}
}
}

@ -19,12 +19,12 @@
*/
package org.libresonic.player.dao;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.libresonic.player.domain.Bookmark;
/**
@ -81,7 +81,7 @@ public class BookmarkDao extends AbstractDao {
update("delete from bookmark where username=? and media_file_id=?", username, mediaFileId);
}
private static class BookmarkRowMapper implements ParameterizedRowMapper<Bookmark> {
private static class BookmarkRowMapper implements RowMapper<Bookmark> {
public Bookmark mapRow(ResultSet rs, int rowNum) throws SQLException {
return new Bookmark(rs.getInt(1), rs.getInt(2), rs.getLong(3), rs.getString(4),
rs.getString(5), rs.getTimestamp(6), rs.getTimestamp(7));

@ -19,12 +19,12 @@
*/
package org.libresonic.player.dao;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.libresonic.player.Logger;
import org.libresonic.player.domain.InternetRadio;
@ -81,7 +81,7 @@ public class InternetRadioDao extends AbstractDao {
update(sql, radio.getName(), radio.getStreamUrl(), radio.getHomepageUrl(), radio.isEnabled(), radio.getChanged(), radio.getId());
}
private static class InternetRadioRowMapper implements ParameterizedRowMapper<InternetRadio> {
private static class InternetRadioRowMapper implements RowMapper<InternetRadio> {
public InternetRadio mapRow(ResultSet rs, int rowNum) throws SQLException {
return new InternetRadio(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getBoolean(5), rs.getTimestamp(6));
}

@ -19,22 +19,15 @@
*/
package org.libresonic.player.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.libresonic.player.domain.Genre;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.domain.MusicFolder;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import static org.libresonic.player.domain.MediaFile.MediaType;
import static org.libresonic.player.domain.MediaFile.MediaType.*;
@ -568,7 +561,7 @@ public class MediaFileDao extends AbstractDao {
update("checkpoint");
}
private static class MediaFileMapper implements ParameterizedRowMapper<MediaFile> {
private static class MediaFileMapper implements RowMapper<MediaFile> {
public MediaFile mapRow(ResultSet rs, int rowNum) throws SQLException {
return new MediaFile(
rs.getInt(1),
@ -604,7 +597,7 @@ public class MediaFileDao extends AbstractDao {
}
}
private static class MusicFileInfoMapper implements ParameterizedRowMapper<MediaFile> {
private static class MusicFileInfoMapper implements RowMapper<MediaFile> {
public MediaFile mapRow(ResultSet rs, int rowNum) throws SQLException {
MediaFile file = new MediaFile();
file.setPlayCount(rs.getInt(1));
@ -614,7 +607,7 @@ public class MediaFileDao extends AbstractDao {
}
}
private static class GenreMapper implements ParameterizedRowMapper<Genre> {
private static class GenreMapper implements RowMapper<Genre> {
public Genre mapRow(ResultSet rs, int rowNum) throws SQLException {
return new Genre(rs.getString(1), rs.getInt(2), rs.getInt(3));
}

@ -19,16 +19,15 @@
*/
package org.libresonic.player.dao;
import org.libresonic.player.Logger;
import org.libresonic.player.domain.MusicFolder;
import org.springframework.jdbc.core.RowMapper;
import java.io.File;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.libresonic.player.Logger;
import org.libresonic.player.domain.MusicFolder;
/**
* Provides database services for music folders.
*
@ -99,7 +98,7 @@ public class MusicFolderDao extends AbstractDao {
}
}
private static class MusicFolderRowMapper implements ParameterizedRowMapper<MusicFolder> {
private static class MusicFolderRowMapper implements RowMapper<MusicFolder> {
public MusicFolder mapRow(ResultSet rs, int rowNum) throws SQLException {
return new MusicFolder(rs.getInt(1), new File(rs.getString(2)), rs.getString(3), rs.getBoolean(4), rs.getTimestamp(5));
}

@ -23,7 +23,6 @@ import java.sql.SQLException;
import java.util.List;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.libresonic.player.domain.SavedPlayQueue;
@ -60,7 +59,7 @@ public class PlayQueueDao extends AbstractDao {
}
}
private static class PlayQueueMapper implements ParameterizedRowMapper<SavedPlayQueue> {
private static class PlayQueueMapper implements RowMapper<SavedPlayQueue> {
public SavedPlayQueue mapRow(ResultSet rs, int rowNum) throws SQLException {
return new SavedPlayQueue(rs.getInt(1),
rs.getString(2),

@ -19,22 +19,13 @@
*/
package org.libresonic.player.dao;
import org.libresonic.player.Logger;
import org.libresonic.player.domain.*;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.libresonic.player.Logger;
import org.libresonic.player.domain.CoverArtScheme;
import org.libresonic.player.domain.Player;
import org.libresonic.player.domain.PlayerTechnology;
import org.libresonic.player.domain.PlayQueue;
import org.libresonic.player.domain.TranscodeScheme;
import java.util.*;
/**
* Provides player-related database services.
@ -95,7 +86,7 @@ public class PlayerDao extends AbstractDao {
* @param player The player to create.
*/
public synchronized void createPlayer(Player player) {
int id = getJdbcTemplate().queryForInt("select max(id) from player") + 1;
int id = getJdbcTemplate().queryForObject("select max(id) from player", Integer.class) + 1;
player.setId(String.valueOf(id));
String sql = "insert into player (" + COLUMNS + ") values (" + questionMarks(COLUMNS) + ")";
update(sql, player.getId(), player.getName(), player.getType(), player.getUsername(),
@ -169,7 +160,7 @@ public class PlayerDao extends AbstractDao {
player.setPlayQueue(playQueue);
}
private class PlayerRowMapper implements ParameterizedRowMapper<Player> {
private class PlayerRowMapper implements RowMapper<Player> {
public Player mapRow(ResultSet rs, int rowNum) throws SQLException {
Player player = new Player();
int col = 1;

@ -23,7 +23,6 @@ import org.libresonic.player.Logger;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.domain.Playlist;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -125,7 +124,7 @@ public class PlaylistDao extends AbstractDao {
new Date(), playlist.getImportedFrom(), playlist.getId());
}
private static class PlaylistMapper implements ParameterizedRowMapper<Playlist> {
private static class PlaylistMapper implements RowMapper<Playlist> {
public Playlist mapRow(ResultSet rs, int rowNum) throws SQLException {
return new Playlist(
rs.getInt(1),

@ -24,7 +24,6 @@ import java.sql.SQLException;
import java.util.List;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.libresonic.player.domain.PodcastChannel;
import org.libresonic.player.domain.PodcastEpisode;
@ -55,7 +54,7 @@ public class PodcastDao extends AbstractDao {
update(sql, null, channel.getUrl(), channel.getTitle(), channel.getDescription(), channel.getImageUrl(),
channel.getStatus().name(), channel.getErrorMessage());
return getJdbcTemplate().queryForInt("select max(id) from podcast_channel");
return getJdbcTemplate().queryForObject("select max(id) from podcast_channel", Integer.class);
}
/**
@ -182,7 +181,7 @@ public class PodcastDao extends AbstractDao {
}
}
private static class PodcastEpisodeRowMapper implements ParameterizedRowMapper<PodcastEpisode> {
private static class PodcastEpisodeRowMapper implements RowMapper<PodcastEpisode> {
public PodcastEpisode mapRow(ResultSet rs, int rowNum) throws SQLException {
return new PodcastEpisode(rs.getInt(1), rs.getInt(2), rs.getString(3), rs.getString(4), rs.getString(5),
rs.getString(6), rs.getTimestamp(7), rs.getString(8), (Long) rs.getObject(9),

@ -26,7 +26,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.springframework.jdbc.core.RowMapper;
import org.libresonic.player.domain.MusicFolder;
import org.libresonic.player.domain.Share;
@ -53,7 +53,7 @@ public class ShareDao extends AbstractDao {
update(sql, null, share.getName(), share.getDescription(), share.getUsername(), share.getCreated(),
share.getExpires(), share.getLastVisited(), share.getVisitCount());
int id = getJdbcTemplate().queryForInt("select max(id) from share");
int id = getJdbcTemplate().queryForObject("select max(id) from share", Integer.class);
share.setId(id);
}
@ -129,14 +129,14 @@ public class ShareDao extends AbstractDao {
update("delete from share where id=?", id);
}
private static class ShareRowMapper implements ParameterizedRowMapper<Share> {
private static class ShareRowMapper implements RowMapper<Share> {
public Share mapRow(ResultSet rs, int rowNum) throws SQLException {
return new Share(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getTimestamp(5),
rs.getTimestamp(6), rs.getTimestamp(7), rs.getInt(8));
}
}
private static class ShareFileRowMapper implements ParameterizedRowMapper<String> {
private static class ShareFileRowMapper implements RowMapper<String> {
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getString(1);
}

@ -23,7 +23,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.springframework.jdbc.core.RowMapper;
import org.libresonic.player.Logger;
import org.libresonic.player.domain.Transcoding;
@ -82,7 +82,7 @@ public class TranscodingDao extends AbstractDao {
* @param transcoding The transcoding to create.
*/
public synchronized void createTranscoding(Transcoding transcoding) {
int id = getJdbcTemplate().queryForInt("select max(id) + 1 from transcoding2");
int id = getJdbcTemplate().queryForObject("select max(id) + 1 from transcoding2", Integer.class);
transcoding.setId(id);
String sql = "insert into transcoding2 (" + COLUMNS + ") values (" + questionMarks(COLUMNS) + ")";
update(sql, transcoding.getId(), transcoding.getName(), transcoding.getSourceFormats(),
@ -115,7 +115,7 @@ public class TranscodingDao extends AbstractDao {
transcoding.getStep3(), transcoding.isDefaultActive(), transcoding.getId());
}
private static class TranscodingRowMapper implements ParameterizedRowMapper<Transcoding> {
private static class TranscodingRowMapper implements RowMapper<Transcoding> {
public Transcoding mapRow(ResultSet rs, int rowNum) throws SQLException {
return new Transcoding(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5),
rs.getString(6), rs.getString(7), rs.getBoolean(8));

@ -19,20 +19,15 @@
*/
package org.libresonic.player.dao;
import org.libresonic.player.Logger;
import org.libresonic.player.domain.*;
import org.libresonic.player.util.StringUtil;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
import org.libresonic.player.Logger;
import org.libresonic.player.domain.AlbumListType;
import org.libresonic.player.domain.AvatarScheme;
import org.libresonic.player.domain.TranscodeScheme;
import org.libresonic.player.domain.User;
import org.libresonic.player.domain.UserSettings;
import org.libresonic.player.util.StringUtil;
/**
* Provides user-related database services.
*
@ -296,7 +291,7 @@ public class UserDao extends AbstractDao {
}
}
private class UserRowMapper implements ParameterizedRowMapper<User> {
private class UserRowMapper implements RowMapper<User> {
public User mapRow(ResultSet rs, int rowNum) throws SQLException {
User user = new User(rs.getString(1), decrypt(rs.getString(2)), rs.getString(3), rs.getBoolean(4),
rs.getLong(5), rs.getLong(6), rs.getLong(7));
@ -305,7 +300,7 @@ public class UserDao extends AbstractDao {
}
}
private static class UserSettingsRowMapper implements ParameterizedRowMapper<UserSettings> {
private static class UserSettingsRowMapper implements RowMapper<UserSettings> {
public UserSettings mapRow(ResultSet rs, int rowNum) throws SQLException {
int col = 1;
UserSettings settings = new UserSettings(rs.getString(col++));

Loading…
Cancel
Save