Package org.hibernate.cfg

Examples of org.hibernate.cfg.Configuration.configure()


            final BootstrapServiceRegistryBuilder bootstrapbuilder = new BootstrapServiceRegistryBuilder();
            builder = new ServiceRegistryBuilder(bootstrapbuilder.build()).applySettings(properties);
            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);
View Full Code Here


            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
View Full Code Here

            // 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);
View Full Code Here

public class DefaultHibernateConfigurerFilterTest extends TestBase
{
    public void configure_with_default_configuration_on() throws Exception
    {
        Configuration config = newMock(Configuration.class);
        expect(config.configure()).andReturn(config);

        replay();

        new DefaultHibernateConfigurer(true).configure(config);
View Full Code Here

    Configuration configuration;
    SchemaExport exporter;
   
    configuration = new Configuration();
    configuration.setProperty("hibernate.dialect", args[0]);
        configuration.configure();   
    exporter = new SchemaExport(configuration);
    exporter.create(true, false);
  }
}
View Full Code Here

@Test
public class DefaultHibernateConfigurerFilterTest {
  public void testConfigure() throws Exception {
    Configuration config = createMock(Configuration.class);
    expect(config.configure()).andReturn(config);
   
    replay(config);
    new DefaultHibernateConfigurer().configure(config);
    verify(config);
  }
View Full Code Here

        if ( args[i].startsWith( "--" ) ) {
          if ( args[i].startsWith( "--properties=" ) ) {
            propFile = args[i].substring( 13 );
          }
          else if ( args[i].startsWith( "--config=" ) ) {
            cfg.configure( args[i].substring( 9 ) );
          }
          else if ( args[i].startsWith( "--naming=" ) ) {
            cfg.setNamingStrategy(
                ( NamingStrategy ) ReflectHelper.classForName( args[i].substring( 9 ) ).newInstance()
            );
View Full Code Here

          }
          else if ( args[i].startsWith( "--delimiter=" ) ) {
            delim = args[i].substring( 12 );
          }
          else if ( args[i].startsWith( "--config=" ) ) {
            cfg.configure( args[i].substring( 9 ) );
          }
          else if ( args[i].startsWith( "--naming=" ) ) {
            cfg.setNamingStrategy(
                ( NamingStrategy ) ReflectHelper.classForName( args[i].substring( 9 ) )
                    .newInstance()
View Full Code Here

    // Allow bundles to put the config file somewhere other than the root level.
    final BundleWiring bundleWiring = (BundleWiring) requestingBundle.adapt( BundleWiring.class );
    final Collection<String> cfgResources = bundleWiring.listResources( "/", "hibernate.cfg.xml",
        BundleWiring.LISTRESOURCES_RECURSE );
    if (cfgResources.size() == 0) {
      configuration.configure();
    }
    else {
      if (cfgResources.size() > 1) {
        LOG.warn( "Multiple hibernate.cfg.xml files found in the persistence bundle.  Using the first one discovered." );
      }
View Full Code Here

    else {
      if (cfgResources.size() > 1) {
        LOG.warn( "Multiple hibernate.cfg.xml files found in the persistence bundle.  Using the first one discovered." );
      }
      String cfgResource = "/" + cfgResources.iterator().next();
      configuration.configure( cfgResource );
    }

    final BootstrapServiceRegistryBuilder builder = new BootstrapServiceRegistryBuilder();
    builder.with( osgiClassLoader );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.