Fix overwriting of data in song_genre_cross table

This commit is contained in:
CappielloAntonio 2021-05-02 16:16:05 +02:00
parent c6254c8416
commit 0305af2f9f
4 changed files with 17 additions and 16 deletions

View file

@ -53,9 +53,17 @@ public class GenreRepository {
}
public void insertAll(ArrayList<Genre> genres) {
InsertAllThreadSafe insertAll = new InsertAllThreadSafe(genreDao, genres);
Thread thread = new Thread(insertAll);
thread.start();
try {
final Thread deleteAll = new Thread(new DeleteAllGenreThreadSafe(genreDao));
final Thread insertAll = new Thread(new InsertAllThreadSafe(genreDao, genres));
deleteAll.start();
deleteAll.join();
insertAll.start();
insertAll.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public void deleteAll() {

View file

@ -21,17 +21,9 @@ public class SongGenreRepository {
}
public void insertAll(List<SongGenreCross> crosses) {
try {
final Thread delete = new Thread(new DeleteAllSongGenreCrossThreadSafe(songGenreCrossDao));
final Thread insertAll = new Thread(new InsertAllThreadSafe(songGenreCrossDao, crosses));
delete.start();
delete.join();
insertAll.start();
insertAll.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
InsertAllThreadSafe insert = new InsertAllThreadSafe(songGenreCrossDao, crosses);
Thread thread = new Thread(insert);
thread.start();
}
public void deleteAll() {