From 914852381662c9d29d504cf51efbd2073e32c265 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 30 Jul 2012 14:57:31 +0200 Subject: [PATCH] Store party links when storing tracks. --- .../net/pterodactylus/demoscenemusic/data/DataManager.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java index ea040bd..f5b071f 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java @@ -457,6 +457,19 @@ public class DataManager { query.addValueField(new ValueField("TRACK_ARTISTS.DISPLAY_ORDER", new IntegerParameter(index + 1))); database.insert(query); } + + /* store party links. */ + Collection parties = track.getParties(); /* prefetch parties. */ + query = new Query(Type.DELETE, "PARTY_TRACKS"); + query.addWhereClause(new ValueFieldWhereClause(new ValueField("PARTY_TRACKS.TRACK", new StringParameter(track.getId())))); + database.update(query); + for (Party party : parties) { + query = new Query(Type.INSERT, "PARTY_TRACKS"); + query.addValueField(new ValueField("PARTY_TRACKS.TRACK", new StringParameter(track.getId()))); + query.addValueField(new ValueField("PARTY_TRACKS.PARTY", new StringParameter(party.getId()))); + database.insert(query); + } + /* store properties. */ saveProperties(track.getProperties(), "TRACK_PROPERTIES", "TRACK", track.getId()); } -- 2.7.4