List of usage examples for org.hibernate.cfg Configuration setProperty
public Configuration setProperty(String propertyName, String value)
From source file:org.jboss.additional.testsuite.jdkall.past.jpa.hibernate.secondlevelcache.SFSB.java
License:Open Source License
@TransactionAttribute(TransactionAttributeType.NEVER) public void setupConfig() { // static {// ww w .ja v a 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.getProperties().put(AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, "jta"); configuration.setProperty(Environment.HBM2DDL_AUTO, "create-drop"); configuration.setProperty(Environment.DATASOURCE, "java:jboss/datasources/ExampleDS"); // 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 ex.printStackTrace(); throw new ExceptionInInitializerError(ex); } }
From source file:org.jboss.as.test.compat.jpa.hibernate.transformer.SFSBHibernateSessionFactory.java
License:Open Source License
public void setupConfig() { // static {/*from www . j av a 2 s .c om*/ 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 throw new RuntimeException("Could not setup config", ex); } }
From source file:org.jboss.as.test.integration.hibernate.envers.SFSBHibernateEnversSessionFactory.java
License:Open Source License
public void setupConfig() { // static {//from w w w . j av a2s . com try { //System.out.println("Current dir : " + (new File(".")).getCanonicalPath()); // 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"); // 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); throw new ExceptionInInitializerError(ex); } }
From source file:org.jboss.as.test.integration.hibernate.naturalid.SFSBHibernateSFNaturalId.java
License:Open Source License
public void setupConfig() { // static {//from w w w. jav a2 s . 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.configure("hibernate.cfg.xml"); // fetch the properties Properties properties = new Properties(); properties.putAll(configuration.getProperties()); Environment.verifyProperties(properties); ConfigurationHelper.resolvePlaceHolders(properties); // build the serviceregistry final BootstrapServiceRegistryBuilder bootstrapbuilder = new BootstrapServiceRegistryBuilder(); serviceRegistry = builder.build(); // Create the SessionFactory from Configuration sessionFactory = configuration.configure("hibernate.cfg.xml").buildSessionFactory(serviceRegistry); } 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.secondlevelcache.SFSB.java
License:Open Source License
@TransactionAttribute(TransactionAttributeType.NEVER) public void setupConfig() { // static {// w w w. j a va 2s .com 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"); // 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); throw new ExceptionInInitializerError(ex); } }
From source file:org.jboss.as.test.integration.hibernate.SFSBHibernate2LcacheStats.java
License:Open Source License
@TransactionAttribute(TransactionAttributeType.NEVER) public void setupConfig() { // static {//from www. j av a2s . 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 {// w w w . ja v a2s. c om 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 ww w. j a v a2 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); 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 www.j a v a 2 s . co 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 ww w . j a v a2 s . c om 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); } }