* */
import java.util.Properties;
-import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.controller.PolicyController;
import org.openecomp.policy.rest.jpa.SystemLogDB;
@SuppressWarnings("deprecation")
public class HibernateSession{
+ private static final Logger LOGGER = FlexLogger.getLogger(HibernateSession.class);
+
private static SessionFactory logSessionFactory;
static {
try {
Properties prop= new Properties();
- prop.setProperty("hibernate.connection.url", PolicyController.logdbUrl);
- prop.setProperty("hibernate.connection.username", PolicyController.logdbUserName);
- prop.setProperty("hibernate.connection.password", PolicyController.logdbPassword);
- prop.setProperty("dialect", PolicyController.logdbDialect);
- prop.setProperty("hibernate.connection.driver_class", PolicyController.logdbDriver);
+ prop.setProperty("hibernate.connection.url", PolicyController.getLogdbUrl());
+ prop.setProperty("hibernate.connection.username", PolicyController.getLogdbUserName());
+ prop.setProperty("hibernate.connection.password", PolicyController.getLogdbPassword());
+ prop.setProperty("dialect", PolicyController.getLogdbDialect());
+ prop.setProperty("hibernate.connection.driver_class", PolicyController.getLogdbDriver());
prop.setProperty("show_sql", "false");
logSessionFactory = new Configuration().addPackage("org.openecomp.policy.*").addProperties(prop)
.addAnnotatedClass(SystemLogDB.class).buildSessionFactory();
- } catch (Throwable ex) {
- throw new ExceptionInInitializerError(ex);
+ } catch (Exception ex) {
+ LOGGER.error("Exception Occured while creating Log database Hibernate session"+ex);
}
}
- public static Session getSession() throws HibernateException {
+ public static Session getSession(){
return logSessionFactory.openSession();
}