package de.linwave.music;
import org.odbms.ObjectContainer;
import org.odbms.ObjectSet;
import org.odbms.Query;
import de.linwave.gtm.GTM;
public class QueryMusic
{
private static ObjectContainer gtm = GTM.getInstance();
private void showAlbum()
{
try {
Query query = gtm.query(Album.class);
query.sortBy("year");
ObjectSet<Album> items = query.execute();
int cnt = 0;
for (Album album : items) {
System.out.println(" [ALBUM " + album.OID + "] " + album.name + " (" + album.year + ")");
String albumArtist = " Artist=";
if (album.artist != null)
albumArtist += album.artist.getName();
else
albumArtist = "<NULL>";
System.out.println(albumArtist);
for (Track track : album.getTracks()) {
System.out.println(" [TRACK " + track.OID + "] " + track.title);
if (track.artist != null) {
System.out.println(" Artist=" + track.artist.name);
}
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static void main(String[] args)
{
try {
QueryMusic music = new QueryMusic();
music.showAlbum();
gtm.printCacheStatistics();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}