From 6bdfd09158a7d212e47ee96ed89dc91a91dad668 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 31 Jul 2012 06:41:08 +0200 Subject: [PATCH] Save groups when saving artist. --- .../net/pterodactylus/demoscenemusic/data/DataManager.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java index f3d3578..8d331cb 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java @@ -190,6 +190,20 @@ public class DataManager { query.addValueField(new ValueField("NAME", new StringParameter(artist.getName()))); query.addWhereClause(new ValueFieldWhereClause(new ValueField("ID", new StringParameter(artist.getId())))); database.update(query); + + /* save groups. */ + Collection groups = artist.getGroups(); + query = new Query(Type.DELETE, "GROUP_ARTISTS"); + query.addWhereClause(new ValueFieldWhereClause(new ValueField("GROUP_ARTISTS.ARTIST", new StringParameter(artist.getId())))); + database.update(query); + for (Group group : groups) { + query = new Query(Type.INSERT, "GROUP_ARTISTS"); + query.addValueField(new ValueField("GROUP_", new StringParameter(group.getId()))); + query.addValueField(new ValueField("ARTIST", new StringParameter(artist.getId()))); + database.insert(query); + } + + /* save properties. */ saveArtistProperties(artist); } -- 2.7.4