List of usage examples for org.hibernate.cfg AvailableSettings USE_NEW_ID_GENERATOR_MAPPINGS
String USE_NEW_ID_GENERATOR_MAPPINGS
To view the source code for org.hibernate.cfg AvailableSettings USE_NEW_ID_GENERATOR_MAPPINGS.
Click Source Link
From source file:org.jboss.as.test.integration.hibernate.SFSBHibernate2LcacheStats.java
License:Open Source License
@TransactionAttribute(TransactionAttributeType.NEVER) public void setupConfig() { // static {//from w w w . ja va2 s . c o m try { //System.out.println("setupConfig: Current dir = " + (new File(".")).getCanonicalPath()); // prepare the configuration Configuration configuration = new Configuration() .setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true"); configuration.getProperties().put(AvailableSettings.JTA_PLATFORM, JBossAppServerJtaPlatform.class); configuration.setProperty(Environment.HBM2DDL_AUTO, "create-drop"); configuration.setProperty(Environment.DATASOURCE, "java:jboss/datasources/ExampleDS"); // set property to enable statistics configuration.setProperty("hibernate.generate_statistics", "true"); // fetch the properties Properties properties = new Properties(); configuration = configuration.configure("hibernate.cfg.xml"); properties.putAll(configuration.getProperties()); Environment.verifyProperties(properties); ConfigurationHelper.resolvePlaceHolders(properties); // build the serviceregistry sessionFactory = configuration.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); } //System.out.println("setupConfig: done"); }
From source file:org.jboss.as.test.integration.hibernate.SFSBHibernateSessionFactory.java
License:Open Source License
public void setupConfig() { // static {//from w w w .ja v a 2s. c o m try { // prepare the configuration Configuration configuration = new Configuration() .setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true"); configuration.setProperty(Environment.HBM2DDL_AUTO, "create-drop"); configuration.setProperty(Environment.DATASOURCE, "java:jboss/datasources/ExampleDS"); configuration.setProperty("hibernate.listeners.envers.autoRegister", "false"); // fetch the properties Properties properties = new Properties(); configuration = configuration.configure("hibernate.cfg.xml"); properties.putAll(configuration.getProperties()); Environment.verifyProperties(properties); ConfigurationHelper.resolvePlaceHolders(properties); sessionFactory = configuration.buildSessionFactory(); } catch (Throwable ex) { // Make sure you log the exception, as it might be swallowed System.err.println("Initial SessionFactory creation failed." + ex); // ex.printStackTrace(); throw new ExceptionInInitializerError(ex); } }
From source file:org.jboss.as.test.integration.hibernate.SFSBHibernateTransaction.java
License:Open Source License
public void setupConfig() { // static {//from w w w . j a va 2 s. c om try { // prepare the configuration Configuration configuration = new Configuration() .setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true"); configuration.getProperties().put(AvailableSettings.JTA_PLATFORM, JBossAppServerJtaPlatform.class); configuration.setProperty(Environment.HBM2DDL_AUTO, "create-drop"); configuration.setProperty(Environment.DATASOURCE, "java:jboss/datasources/ExampleDS"); configuration.setProperty("hibernate.listeners.envers.autoRegister", "false"); // fetch the properties Properties properties = new Properties(); configuration = configuration.configure("hibernate.cfg.xml"); properties.putAll(configuration.getProperties()); Environment.verifyProperties(properties); ConfigurationHelper.resolvePlaceHolders(properties); sessionFactory = configuration.buildSessionFactory(); } catch (Throwable ex) { // Make sure you log the exception, as it might be swallowed System.err.println("Initial SessionFactory creation failed." + ex); // ex.printStackTrace(); throw new ExceptionInInitializerError(ex); } }
From source file:org.jboss.as.test.integration.hibernate.SFSBHibernatewithCriteriaSession.java
License:Open Source License
public void setupConfig() { // static {/*from w w w .j a v a 2 s .c o m*/ try { // prepare the configuration Configuration configuration = new Configuration() .setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true"); configuration.getProperties().put(AvailableSettings.JTA_PLATFORM, JBossAppServerJtaPlatform.class); configuration.setProperty(Environment.HBM2DDL_AUTO, "create-drop"); configuration.setProperty(Environment.DATASOURCE, "java:jboss/datasources/ExampleDS"); configuration.setProperty("hibernate.listeners.envers.autoRegister", "false"); // fetch the properties Properties properties = new Properties(); configuration = configuration.configure("hibernate.cfg.xml"); properties.putAll(configuration.getProperties()); Environment.verifyProperties(properties); ConfigurationHelper.resolvePlaceHolders(properties); // build the serviceregistry StandardServiceRegistryBuilder registry = new StandardServiceRegistryBuilder() .applySettings(properties); sessionFactory = configuration.buildSessionFactory(registry.build()); // build metamodel SessionFactoryImplementor sfi = (SessionFactoryImplementor) sessionFactory; MetamodelImpl.buildMetamodel(configuration.getClassMappings(), sfi); sessionFactory.getStatistics().setStatisticsEnabled(true); } catch (Throwable ex) { // Make sure you log the exception, as it might be swallowed System.err.println("Initial SessionFactory creation failed." + ex); // ex.printStackTrace(); throw new ExceptionInInitializerError(ex); } }
From source file:org.jboss.as.test.integration.hibernate.SFSBHibernatewithMetaDataSession.java
License:Open Source License
public void setupConfig() { // static {//from w w w .j a va 2s. co m try { // prepare the configuration Configuration configuration = new Configuration() .setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true"); configuration.setProperty(Environment.HBM2DDL_AUTO, "create-drop"); configuration.setProperty(Environment.DATASOURCE, "java:jboss/datasources/ExampleDS"); configuration.setProperty("hibernate.listeners.envers.autoRegister", "false"); // fetch the properties Properties properties = new Properties(); configuration = configuration.configure("hibernate.cfg.xml"); properties.putAll(configuration.getProperties()); Environment.verifyProperties(properties); ConfigurationHelper.resolvePlaceHolders(properties); StandardServiceRegistryBuilder registry = new StandardServiceRegistryBuilder() .applySettings(properties); sessionFactory = configuration.buildSessionFactory(registry.build()); // build metamodel SessionFactoryImplementor sfi = (SessionFactoryImplementor) sessionFactory; MetamodelImpl.buildMetamodel(configuration.getClassMappings(), sfi); sessionFactory.getStatistics().setStatisticsEnabled(true); } catch (Throwable ex) { // Make sure you log the exception, as it might be swallowed System.err.println("Initial SessionFactory creation failed." + ex); // ex.printStackTrace(); throw new ExceptionInInitializerError(ex); } }
From source file:org.springframework.boot.autoconfigure.orm.jpa.HibernateProperties.java
License:Apache License
private void applyNewIdGeneratorMappings(Map<String, Object> result) { if (this.useNewIdGeneratorMappings != null) { result.put(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, this.useNewIdGeneratorMappings.toString()); } else if (!result.containsKey(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS)) { result.put(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true"); }/*from ww w . jav a 2s . c o m*/ }
From source file:org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesTests.java
License:Apache License
@Test public void useNewIdGeneratorMappingsDefault() { this.contextRunner.run(assertHibernateProperties((hibernateProperties) -> assertThat(hibernateProperties) .containsEntry(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true"))); }
From source file:org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesTests.java
License:Apache License
@Test public void useNewIdGeneratorMappingsFalse() { this.contextRunner.withPropertyValues("spring.jpa.hibernate.use-new-id-generator-mappings:false") .run(assertHibernateProperties((hibernateProperties) -> assertThat(hibernateProperties) .containsEntry(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "false"))); }
From source file:org.springframework.boot.autoconfigure.orm.jpa.JpaPropertiesTests.java
License:Apache License
@Test public void useNewIdGeneratorMappingsDefaultHibernate4() throws Exception { JpaProperties properties = load(HibernateVersion.V4); Map<String, String> hibernateProperties = properties.getHibernateProperties(mockStandaloneDataSource()); assertThat(hibernateProperties).doesNotContainKey(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS); }
From source file:org.springframework.boot.autoconfigure.orm.jpa.JpaPropertiesTests.java
License:Apache License
@Test public void useNewIdGeneratorMappingsDefaultHibernate5() throws Exception { JpaProperties properties = load(HibernateVersion.V5); Map<String, String> hibernateProperties = properties.getHibernateProperties(mockStandaloneDataSource()); assertThat(hibernateProperties).containsEntry(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "false"); }