PreparedStatement st = null;
ResultSet rs = null;
try {
final Database db = getDatabase();
// use the date the track was played instead of the date it
// was added to the collection.
final String sql = Utils.replaceAll( "t.date_added", "l.date_played", Track.getSelectSql() ) +
" from play_log l " +
" inner join tracks t " +
" on t.id = l.track_id " +
" inner join artists ar " +
" on ar.id = t.artist_id " +
" inner join albums al " +
" on al.id = t.album_id " +
" inner join genres g " +
" on g.id = t.genre_id " +
" where l.user_id = ? " +
" and l.scrobbled = 0 ";
st = db.prepare( sql );
st.setInt( 1, user.getId() );
rs = st.executeQuery();
return Track.createListFromResultSet( rs );