diff --git a/pom.xml b/pom.xml index 4f3cc66..17609f4 100644 --- a/pom.xml +++ b/pom.xml @@ -70,13 +70,13 @@ org.hibernate hibernate-core - 5.0.7.Final + 5.1.1.Final compile org.hibernate hibernate-c3p0 - 5.0.7.Final + 5.1.1.Final org.hsqldb diff --git a/src/main/java/musicplayer/db/HibernateDatabase.java b/src/main/java/musicplayer/db/HibernateDatabase.java index 50a61b2..46213fe 100644 --- a/src/main/java/musicplayer/db/HibernateDatabase.java +++ b/src/main/java/musicplayer/db/HibernateDatabase.java @@ -8,6 +8,7 @@ import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Restrictions; +import java.util.Arrays; import java.util.List; import java.util.Optional; import java.util.Properties; @@ -57,6 +58,7 @@ public class HibernateDatabase implements IDatabase{ } sessionFactory = new Configuration() .addProperties(properties) + .addPackage("musicplayer.model") .addAnnotatedClass(Album.class) .addAnnotatedClass(Artist.class) .addAnnotatedClass(Song.class) @@ -116,7 +118,8 @@ public class HibernateDatabase implements IDatabase{ try(Session session = getSession()) { session.beginTransaction(); @SuppressWarnings("unchecked") - List songs = (List)session.createCriteria(Song.class).add(Restrictions.not(Restrictions.in("id", ids))).list(); + List songs = (List)session.createCriteria(Song.class).add(Restrictions.not(Restrictions.in + ("id", Arrays.asList(ids)))).list(); if(songs != null && !songs.isEmpty()) songs.forEach(session::delete); session.getTransaction().commit();