X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=esr-mgr%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fesr%2Fcommon%2FHibernateSession.java;fp=esr-mgr%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fesr%2Fcommon%2FHibernateSession.java;h=0000000000000000000000000000000000000000;hb=e5810e581bfb1fa7fb7783e16a41eb79564e9934;hp=963ccc7cda71f5972445c059a07021c4569a81b6;hpb=6011cbc9b4031f3ce25a82ccb1c0fedf4a2bf57a;p=aai%2Fesr-server.git diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/common/HibernateSession.java b/esr-mgr/src/main/java/org/onap/aai/esr/common/HibernateSession.java deleted file mode 100644 index 963ccc7..0000000 --- a/esr-mgr/src/main/java/org/onap/aai/esr/common/HibernateSession.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright 2017 ZTE Corporation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onap.aai.esr.common; - -import java.io.File; -import java.net.URISyntaxException; - -import org.hibernate.SessionFactory; -import org.hibernate.boot.registry.StandardServiceRegistryBuilder; -import org.hibernate.cfg.Configuration; -import org.hibernate.service.ServiceRegistry; - -public class HibernateSession { - private static File cfgfile = null; - - private static ServiceRegistry serviceRegistry = null; - private static Configuration configuration = null; - private static SessionFactory sessionFactory = null; - private static String resourcePath; - - /** - * Get a hibernate sessionFactory. - */ - public static SessionFactory init() { - initConfigure(); - configuration = new Configuration().configure(cfgfile); - configuration.setProperty("hibernate.connection.url", "jdbc:h2:tcp://localhost:8205/" - + resourcePath + "db/catalog"); - serviceRegistry = - new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build(); - sessionFactory = configuration.buildSessionFactory(serviceRegistry); - return sessionFactory; - } - - private static void initConfigure() { - try { - resourcePath = HibernateSession.class.getResource("/").toURI().getPath(); - } catch (URISyntaxException e1) { - e1.printStackTrace(); - } - final String filename = "Hibernate.cfg.xml"; - cfgfile = new File(resourcePath + filename); - } - - /** - * Destory a hibernate sessionFactory. - */ - public static void destory() { - if (sessionFactory != null && !sessionFactory.isClosed()) { - sessionFactory.close(); - } - } - - /** - * test. - * @param args param - */ - public static void main(String[] args) { - - } -}