Updated Hibernate to 5.1.1.Final.

This commit is contained in:
neviyn 2016-08-19 16:44:46 +01:00
parent 2d75adf6ac
commit 075b2fea8f
2 changed files with 6 additions and 3 deletions

View File

@ -70,13 +70,13 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.0.7.Final</version>
<version>5.1.1.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>5.0.7.Final</version>
<version>5.1.1.Final</version>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>

View File

@ -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<Song> songs = (List<Song>)session.createCriteria(Song.class).add(Restrictions.not(Restrictions.in("id", ids))).list();
List<Song> songs = (List<Song>)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();