Query query = new Query(Type.SELECT, "TRACKS");
query.addField(new Field("TRACKS.*"));
query.addWhereClause(new ValueFieldWhereClause(new ValueField("TRACKS.ID", new StringParameter(id))));
- return database.getSingle(query, trackCreator);
+ return loadTrackProperties(database.getSingle(query, trackCreator));
}
/**
query.addField(new Field("TRACKS.*"));
query.addJoin(new Join(JoinType.INNER, "TRACK_ARTISTS", new Field("TRACKS.ID"), new Field("TRACK_ARTISTS.TRACK")));
query.addWhereClause(new ValueFieldWhereClause(new ValueField("TRACK_ARTISTS.ARTIST", new StringParameter(artistId))));
- return database.getMultiple(query, trackCreator);
+ return loadTrackProperties(database.getMultiple(query, trackCreator));
+ }
+
+ /**
+ * Loads the properties for the given track.
+ *
+ * @param track
+ * The track for which to load the properties
+ * @return The track with the properties loaded
+ * @throws DatabaseException
+ * if a database error occurs
+ */
+ public Track loadTrackProperties(Track track) throws DatabaseException {
+ return loadProperties(track, "TRACK_PROPERTIES", "TRACK");
+ }
+
+ /**
+ * Loads the properties for the given tracks.
+ *
+ * @param tracks
+ * The tracks for which to load the properties
+ * @return The tracks with the properties loaded
+ * @throws DatabaseException
+ * if a database error occurs
+ */
+ public List<Track> loadTrackProperties(List<Track> tracks) throws DatabaseException {
+ for (Track track : tracks) {
+ loadTrackProperties(track);
+ }
+ return tracks;
}
/**