当前位置: 首页>>代码示例>>Java>>正文


Java StandardServiceRegistryBuilder.destroy方法代码示例

本文整理汇总了Java中org.hibernate.boot.registry.StandardServiceRegistryBuilder.destroy方法的典型用法代码示例。如果您正苦于以下问题:Java StandardServiceRegistryBuilder.destroy方法的具体用法?Java StandardServiceRegistryBuilder.destroy怎么用?Java StandardServiceRegistryBuilder.destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.boot.registry.StandardServiceRegistryBuilder的用法示例。


在下文中一共展示了StandardServiceRegistryBuilder.destroy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSessionFactory

import org.hibernate.boot.registry.StandardServiceRegistryBuilder; //导入方法依赖的package包/类
public static SessionFactory getSessionFactory() {
    if (sessionFactory == null) {
        StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
                .configure() // configures settings from hibernate.cfg.xml
                .build();
        try {
            sessionFactory = new MetadataSources(registry).buildMetadata().buildSessionFactory();
        } catch (Exception e) {
            // The registry would be destroyed by the SessionFactory, but we had trouble building the SessionFactory
            // so destroy it manually.
            StandardServiceRegistryBuilder.destroy(registry);
            throw new RuntimeException(e);
        }
    }
    return sessionFactory;
}
 
开发者ID:mavogel,项目名称:hska-vis-legacy,代码行数:17,代码来源:HibernateUtil.java

示例2: setUp

import org.hibernate.boot.registry.StandardServiceRegistryBuilder; //导入方法依赖的package包/类
@BeforeClass
protected void setUp() throws Exception {
    // A SessionFactory is set up once for an application!
    final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
            .configure() // configures settings from hibernate.cfg.xml
            .build();
    try {
        sessionFactory = new MetadataSources(registry).buildMetadata().buildSessionFactory();
    }
    catch (Exception e) {
        e.printStackTrace();
        // The registry would be destroyed by the SessionFactory, but we had trouble building the SessionFactory
        // so destroy it manually.
        StandardServiceRegistryBuilder.destroy( registry );
    }
}
 
开发者ID:SpaceHead1C,项目名称:module-template,代码行数:17,代码来源:HbConnectionTest.java

示例3: init

import org.hibernate.boot.registry.StandardServiceRegistryBuilder; //导入方法依赖的package包/类
private static void init() {
    // 从hibernate.cfg.xml文件初始化
    final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
            .configure() // configures settings from hibernate.cfg.xml
            .build();
    try {
        // build 一个sessionFactory
        sessionFactory = new MetadataSources(registry)
                .buildMetadata()
                .buildSessionFactory();
    } catch (Exception e) {
        e.printStackTrace();
        // 错误则打印输出,并销毁
        StandardServiceRegistryBuilder.destroy(registry);
    }
}
 
开发者ID:FZZFVII,项目名称:pipe,代码行数:17,代码来源:Hib.java

示例4: HibernateUserDao

import org.hibernate.boot.registry.StandardServiceRegistryBuilder; //导入方法依赖的package包/类
public HibernateUserDao() {
	// hibernate5
	final StandardServiceRegistry registry = new StandardServiceRegistryBuilder().configure() // configures
			.build();
	try {
		sessionFactory = new MetadataSources(registry).buildMetadata().buildSessionFactory();
	} catch (Exception e) {
		// The registry would be destroyed by the SessionFactory, but we had
		// trouble building the SessionFactory
		// so destroy it manually.
		StandardServiceRegistryBuilder.destroy(registry);
	}

	// hibernate4
	// try {
	// // Create the SessionFactory from hibernate.cfg.xml
	// sessionFactory = new
	// Configuration().configure().buildSessionFactory();
	// } catch (Throwable ex) {
	// // Make sure you log the exception, as it might be swallowed
	// System.err.println("Initial SessionFactory creation failed." + ex);
	// throw new ExceptionInInitializerError(ex);
	// }
}
 
开发者ID:lf23617358,项目名称:training-sample,代码行数:25,代码来源:HibernateUserDao.java

示例5: setUp

import org.hibernate.boot.registry.StandardServiceRegistryBuilder; //导入方法依赖的package包/类
@BeforeClass
protected void setUp() throws Exception {
    // A SessionFactory is set up once for an application!
    final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
            .configure() // configures settings from hibernate.cfg.xml
            .build();
    try {
        sessionFactory = new MetadataSources( registry ).buildMetadata().buildSessionFactory();
    }
    catch (Exception e) {
        e.printStackTrace();
        // The registry would be destroyed by the SessionFactory, but we had trouble building the SessionFactory
        // so destroy it manually.
        StandardServiceRegistryBuilder.destroy( registry );
    }
}
 
开发者ID:LadyTurandot,项目名称:Java_Good,代码行数:17,代码来源:HbConnectionTest.java

示例6: start

import org.hibernate.boot.registry.StandardServiceRegistryBuilder; //导入方法依赖的package包/类
@Override
public void start() {
    StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
            .applySetting("hibernate.connection.username", config.persistence.user)
            .applySetting("hibernate.connection.password", config.persistence.pass)
            .applySetting("hibernate.connection.driver_class", config.persistence.driver)
            .applySetting("hibernate.connection.url", config.persistence.url)
            .applySetting("hibernate.dialect", config.persistence.dialect)
            .applySetting("hibernate.connection.pool_size", config.persistence.pool_size + "")
            .applySetting("hibernate.hbm2ddl.auto", "update")
            .applySetting("hibernate.show_sql", config.persistence.showSQL + "")
            .build();

    MetadataSources sources = new MetadataSources(registry);

    Timings.time("RegisterDBEntities", () ->
            new Reflections().getTypesAnnotatedWith(Entity.class).forEach(sources::addAnnotatedClass));

    try {
        Metadata metadata = sources.buildMetadata();
        sessionFactory = metadata.buildSessionFactory();
    } catch (Exception e) {
        StandardServiceRegistryBuilder.destroy(registry);
        e.printStackTrace();
    }
}
 
开发者ID:VoxelGamesLib,项目名称:VoxelGamesLib,代码行数:27,代码来源:HibernatePersistenceProvider.java

示例7: buildSessionFactory

import org.hibernate.boot.registry.StandardServiceRegistryBuilder; //导入方法依赖的package包/类
/**
 * Created by admin on 10.01.2017.
 * @return SessionFactory
 */
protected static SessionFactory buildSessionFactory() {
    // A SessionFactory is set up once for an application!
    final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
            .configure() // configures settings from hibernate.cfg.xml
            .build();
    try {
        sessionFactory = new MetadataSources(registry).buildMetadata().buildSessionFactory();
    } catch (Exception e) {
        // The registry would be destroyed by the SessionFactory, but we had trouble building the SessionFactory
        // so destroy it manually.
        StandardServiceRegistryBuilder.destroy(registry);

        throw new ExceptionInInitializerError("Initial SessionFactory failed" + e);
    }
    return sessionFactory;
}
 
开发者ID:SergeyZhernovoy,项目名称:Java-education,代码行数:21,代码来源:HibernateSessionFactory.java

示例8: buildSessionFactory

import org.hibernate.boot.registry.StandardServiceRegistryBuilder; //导入方法依赖的package包/类
/**
 * Created by admin on 30.12.2016.
 * create factory
 * @return SessionFactory
 */
protected static SessionFactory buildSessionFactory() {
    // A SessionFactory is set up once for an application!
    final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
            .configure() // configures settings from hibernate.cfg.xml
            .build();
    try {
        sessionFactory = new MetadataSources(registry).buildMetadata().buildSessionFactory();
    } catch (Exception e) {
        // The registry would be destroyed by the SessionFactory, but we had trouble building the SessionFactory
        // so destroy it manually.
        StandardServiceRegistryBuilder.destroy(registry);

        throw new ExceptionInInitializerError("Initial SessionFactory failed" + e);
    }
    return sessionFactory;
}
 
开发者ID:SergeyZhernovoy,项目名称:Java-education,代码行数:22,代码来源:HibernateSessionFactory.java

示例9: setUp

import org.hibernate.boot.registry.StandardServiceRegistryBuilder; //导入方法依赖的package包/类
@BeforeClass
protected void setUp() throws Exception {
  // A SessionFactory is set up once for an application!
  final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
          .configure() // configures settings from hibernate.cfg.xml
          .build();
  try {
    sessionFactory = new MetadataSources( registry ).buildMetadata().buildSessionFactory();
  }
  catch (Exception e) {
    e.printStackTrace();
    // The registry would be destroyed by the SessionFactory, but we had trouble building the SessionFactory
    // so destroy it manually.
    StandardServiceRegistryBuilder.destroy( registry );
  }
}
 
开发者ID:barancev,项目名称:java_pft,代码行数:17,代码来源:HbConnectionTest.java

示例10: setUpDb

import org.hibernate.boot.registry.StandardServiceRegistryBuilder; //导入方法依赖的package包/类
@BeforeClass
public void setUpDb() throws Exception {
    // A SessionFactory is set up once for an application!
    final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
            .configure() // configures settings from hibernate.cfg.xml
            .build();
    try {
        sessionFactory = new MetadataSources( registry ).buildMetadata().buildSessionFactory();
    }
    catch (Exception e) {
        e.printStackTrace();
        // The registry would be destroyed by the SessionFactory, but we had trouble building the SessionFactory
        // so destroy it manually.
        StandardServiceRegistryBuilder.destroy( registry );
    }
}
 
开发者ID:ragrigor,项目名称:JAVA_rep1,代码行数:17,代码来源:ContactDeleteFromGroupTests.java

示例11: buildSessionFactory

import org.hibernate.boot.registry.StandardServiceRegistryBuilder; //导入方法依赖的package包/类
public static SessionFactory buildSessionFactory() {
	final StandardServiceRegistry registry = new StandardServiceRegistryBuilder().configure() // configures
			.build();
	try {
		sessionFactory = new MetadataSources(registry).buildMetadata().buildSessionFactory();
	} catch (Exception e) {
		// The registry would be destroyed by the SessionFactory, but we had
		// trouble building the SessionFactory
		// so destroy it manually.
		StandardServiceRegistryBuilder.destroy(registry);
	}
	return sessionFactory;
}
 
开发者ID:lf23617358,项目名称:training-sample,代码行数:14,代码来源:HibernateUtil.java

示例12: setUp

import org.hibernate.boot.registry.StandardServiceRegistryBuilder; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
            .configure() // configures settings from hibernate.cfg.xml
            .build();
    try {
        sessionFactory = new MetadataSources(registry).buildMetadata().buildSessionFactory();
    } catch (Exception e) {
        StandardServiceRegistryBuilder.destroy(registry);
    }
}
 
开发者ID:dongkuo,项目名称:ssh-example,代码行数:12,代码来源:TestHibernate.java

示例13: HibernateUtil

import org.hibernate.boot.registry.StandardServiceRegistryBuilder; //导入方法依赖的package包/类
public HibernateUtil(ArgumentParser argumentParser, WebLogParser logParser) throws ExceptionInInitializerError, IOException, CannotCompileException, NotFoundException {
	try {
		/** Izbrisemo razrede, ki jih je uprabnik podal za ignoriranje */
		List<LogFieldType> list = logParser.getFieldType();
		if (logParser.getIgnoreFieldTypes() != null) {
			list.removeAll(logParser.getIgnoreFieldTypes());
		}
		/** Inicializacija ClassLoaderja */
		this.loader = initClassLoader(argumentParser);
		/** Nastavi dodatne lastnosti za Hibernate */
		Properties props = initProperties(argumentParser);
		/** Nastavi nastavitve za Hibernate */
		serviceRegistry = new StandardServiceRegistryBuilder()
				/** Dodaj nov ClassLoader Hibernatu */
				.addService(ClassLoaderService.class, new ClassLoaderServiceImpl(loader))
				/** Podaj nastavitve za Hibernate */
				.applySettings(props)
				.build();
		/** Posreduj potrebene razrede za izdelavo in delovanje podatkovne baze Hibernatu */
		MetadataSources sources = new MetadataSources(serviceRegistry);
		for (Class c : initClasses(list, loader)) {
			sources.addAnnotatedClass(c);
		}
		/** Izdelaj podatkovno bazo */
		factory = sources.buildMetadata().buildSessionFactory();
	} catch (Exception e) {
		StandardServiceRegistryBuilder.destroy(serviceRegistry);
		throw new ExceptionInInitializerError(e);
	}
}
 
开发者ID:kb2623,项目名称:spletne-seje,代码行数:31,代码来源:HibernateUtil.java

示例14: close

import org.hibernate.boot.registry.StandardServiceRegistryBuilder; //导入方法依赖的package包/类
@Override
public void close() {
	if (factory != null) {
		factory.close();
	}
	if (serviceRegistry != null) {
		StandardServiceRegistryBuilder.destroy(serviceRegistry);
	}
}
 
开发者ID:kb2623,项目名称:spletne-seje,代码行数:10,代码来源:HibernateUtil.java

示例15: start

import org.hibernate.boot.registry.StandardServiceRegistryBuilder; //导入方法依赖的package包/类
@Override
public void start() {
    // don't judge me, bukkit doesn't want to resolve those so we need to manually load them
    Class[] iDontEvenKnow = new Class[]{CoreMessageLogger_$logger.class, Log_$logger.class,
            ConnectionPoolingLogger_$logger.class, EntityManagerMessageLogger_$logger.class, ConnectionAccessLogger_$logger.class};

    boolean shouldCreateTable = config.persistence.initialTableCreation;
    if (shouldCreateTable) {
        config.persistence.initialTableCreation = false;
        configHandler.saveGlobalConfig();
    }

    StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
            // credentials and stuff
            .applySetting("hibernate.connection.username", config.persistence.user)
            .applySetting("hibernate.connection.password", config.persistence.pass)
            .applySetting("hibernate.connection.driver_class", config.persistence.driver)
            .applySetting("hibernate.connection.url", config.persistence.url + "?useSSL=false")
            .applySetting("hibernate.dialect", config.persistence.dialect)
            // misc settings
            .applySetting("hibernate.hbm2ddl.auto", shouldCreateTable ? "create" : "update")
            .applySetting("hibernate.show_sql", config.persistence.showSQL + "")
            //TODO apparently this is an anti-pattern [0], but it fixes an issue so ¯\_(ツ)_/¯
            // [0]: https://vladmihalcea.com/2016/09/05/the-hibernate-enable_lazy_load_no_trans-anti-pattern/
            .applySetting("hibernate.enable_lazy_load_no_trans", true)
            .applySetting("hibernate.connection.autocommit", true)
            // connection pool
            .applySetting("hibernate.connection.pool_size", config.persistence.pool_size + "")
            //TODO figure out how to use hikari with hibernate
            //.applySetting("hibernate.connection.provider_class","com.zaxxer.hikari.hibernate.HikariConnectionProvider")
            .build();

    JavaTypeDescriptorRegistry.INSTANCE.addDescriptor(ComponentTypeDescriptor.INSTANCE);

    MetadataSources sources = new MetadataSources(registry);

    Timings.time("RegisterDBEntities", () ->
            new Reflections("").getTypesAnnotatedWith(Entity.class).forEach(sources::addAnnotatedClass));

    try {
        Metadata metadata = sources.buildMetadata();
        sessionFactory = metadata.buildSessionFactory();
    } catch (Exception e) {
        StandardServiceRegistryBuilder.destroy(registry);
        e.printStackTrace();
    }
}
 
开发者ID:VoxelGamesLib,项目名称:VoxelGamesLibv2,代码行数:48,代码来源:HibernatePersistenceProvider.java


注:本文中的org.hibernate.boot.registry.StandardServiceRegistryBuilder.destroy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。