diff --git a/src/main/java/musicplayer/db/HibernateDatabase.java b/src/main/java/musicplayer/db/HibernateDatabase.java index d7fce91..d5e2ef9 100644 --- a/src/main/java/musicplayer/db/HibernateDatabase.java +++ b/src/main/java/musicplayer/db/HibernateDatabase.java @@ -35,19 +35,20 @@ public class HibernateDatabase implements IDatabase{ Properties properties = new Properties(); if (sessionFactory != null) sessionFactory.close(); + + // Common properties + properties.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"); + properties.put("hibernate.connection.driver_class", "org.hsqldb.jdbc.JDBCDriver"); + properties.put("hibernate.enable_lazy_load_no_trans", "true"); + if(testMode){ - properties.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"); - properties.put("hibernate.connection.driver_class", "org.hsqldb.jdbc.JDBCDriver"); properties.put("hibernate.connection.url", "jdbc:hsqldb:mem:."); properties.put("hibernate.hbm2ddl.auto", "create-drop"); - properties.put("hibernate.enable_lazy_load_no_trans", "true"); } else{ - properties.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"); - properties.put("hibernate.connection.driver_class", "org.hsqldb.jdbc.JDBCDriver"); properties.put("hibernate.connection.url", ConfigManager.getDatabaseConnectionString()); properties.put("hibernate.hbm2ddl.auto", "update"); - properties.put("hibernate.enable_lazy_load_no_trans", "true"); + } sessionFactory = new Configuration() .addProperties(properties) diff --git a/src/main/java/musicplayer/library/JTreeLibrary.java b/src/main/java/musicplayer/library/JTreeLibrary.java index 831a967..844531f 100644 --- a/src/main/java/musicplayer/library/JTreeLibrary.java +++ b/src/main/java/musicplayer/library/JTreeLibrary.java @@ -24,6 +24,7 @@ import java.io.File; import java.nio.file.Path; import java.util.*; import java.util.List; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; @@ -37,7 +38,7 @@ public class JTreeLibrary extends JPanel implements ILibrary, LibraryCallbackInt private final JXTextField librarySearchField = new JXTextField(); final JTree libraryTree = new JTree(); private final Map libraryDisplayVariants = createDisplayVariantMap(); - private final static Map albumArt = new HashMap<>(); + private final static Map albumArt = new ConcurrentHashMap<>(); private Thread albumArtCollector; /**