Package org.hibernate.service

Examples of org.hibernate.service.ServiceRegistryBuilder


    protected SessionFactory buildSessionFactory() {
        Configuration conf = getHibernateConfiguration();

        BootstrapServiceRegistry bootstrapRegistry = createHibernateBootstrapServiceRegistry();

        final ServiceRegistry serviceRegistry = new ServiceRegistryBuilder(bootstrapRegistry).applySettings(
                conf.getProperties()).buildServiceRegistry();
        conf.setSessionFactoryObserver(new SessionFactoryObserver() {
            @Override
            public void sessionFactoryCreated(SessionFactory factory) {
            }
View Full Code Here


  }

  private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) {
    Environment.verifyProperties( properties );
    ConfigurationHelper.resolvePlaceHolders( properties );
    return (StandardServiceRegistryImpl) new ServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry();
  }
View Full Code Here

  SessionFactory buildSessionFactory() throws HibernateException {
        LOG.startingServiceAtJndiName( boundName );
        LOG.serviceProperties( properties );
        return buildConfiguration().buildSessionFactory(
        new ServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry()
    );
  }
View Full Code Here

  }

  private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) {
    Environment.verifyProperties( properties );
    ConfigurationHelper.resolvePlaceHolders( properties );
    return (StandardServiceRegistryImpl) new ServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry();
  }
View Full Code Here

  }

  private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) {
    Environment.verifyProperties( properties );
    ConfigurationHelper.resolvePlaceHolders( properties );
    return (StandardServiceRegistryImpl) new ServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry();
  }
View Full Code Here

   * @deprecated Use {@link #buildSessionFactory(ServiceRegistry)} instead
   */
  public SessionFactory buildSessionFactory() throws HibernateException {
    Environment.verifyProperties( properties );
    ConfigurationHelper.resolvePlaceHolders( properties );
    final ServiceRegistry serviceRegistry =  new ServiceRegistryBuilder()
        .applySettings( properties )
        .buildServiceRegistry();
    setSessionFactoryObserver(
        new SessionFactoryObserver() {
          @Override
View Full Code Here

    properties.putAll( configuration.getProperties() );
    Environment.verifyProperties( properties );
    ConfigurationHelper.resolvePlaceHolders( properties );

    final BootstrapServiceRegistry bootstrapServiceRegistry = generateBootstrapRegistry( properties );
    ServiceRegistryBuilder registryBuilder = new ServiceRegistryBuilder( bootstrapServiceRegistry )
        .applySettings( properties );
    prepareBasicRegistryBuilder( registryBuilder );
    return (StandardServiceRegistryImpl) registryBuilder.buildServiceRegistry();
  }
View Full Code Here

  protected void doStart() {

    final Configuration configuration = getConfiguration();
    if (schemaUpdate) {
      ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
      builder.applySettings(configuration.getProperties());
      SchemaUpdate update = new SchemaUpdate(builder.buildServiceRegistry(), configuration);
     
      // classic schemaupdate execution, will work with all releases
      if(outputFileName == null && delimiter == null && haltOnError && format)
        update.execute(scriptToConsole, exportToDatabase);

      // at least one of the parameter unmanaged by
      // hibernate core prior versions is set
      else {
       
        /* working with reflection as no idea what hibernate core version is used */
        try {
          Class schemaUpdateClass = SchemaUpdate.class;
         
          if (null != outputFileName) {
            Method setOutputFile = schemaUpdateClass.getMethod("setOutputFile",
                new Class[] {String.class});
            setOutputFile.invoke(update, new Object[] {new File(getOutputDirectory(),
                outputFileName).toString()});
                   
            log.debug("delimiter ='"+ delimiter + "'");
            Method setDelimiter = schemaUpdateClass.getMethod("setDelimiter",
                new Class[] {String.class});
            setDelimiter.invoke(update, new Object[] {delimiter});
           
            Method setFormat = schemaUpdateClass.getMethod("setFormat",
                new Class[] {boolean.class});
            setFormat.invoke(update, new Object[] {Boolean.valueOf(format)});
           
          }
         
          if (haltOnError) {
            Method setHaltOnError = schemaUpdateClass.getMethod("setHaltOnError",
                new Class[] {boolean.class});
            setHaltOnError.invoke(update, new Object[] {Boolean.valueOf(haltOnError)});
          }
         
          update.execute(scriptToConsole, exportToDatabase);
          if (!update.getExceptions().isEmpty()) {
            int i = 1;
            for (Iterator iterator = update.getExceptions().iterator(); iterator
                .hasNext(); i++) {
              Throwable element = (Throwable) iterator.next();
              log.warn("Error #" + i + ": ", element);

            }
            log.error(i - 1 + " errors occurred while performing Hbm2DDLExporter.");
            if (haltOnError) {
              throw new ExporterException(
                  "Errors while performing Hbm2DDLExporter");
            }
          }
         
        } catch (NoSuchMethodException e) {
          log.error( "Error during DDL export, this version of hibernate doesn't support following " +
              "SchemaUpdate parameters: haltonerror = true, format= true, delimiter and outputfilename" +
              " either update hibernate jar or don't used the involved parameters", e );
        } catch (IllegalArgumentException e) {
          log.error( "Error during DDL export, this version of hibernate doesn't support following " +
              "SchemaUpdate parameters: haltonerror = true, format= true, delimiter and outputfilename" +
              " either update hibernate jar or don't used the involved parameters", e );
        } catch (InvocationTargetException e) {
          log.error( "Error during DDL export, this version of hibernate doesn't support following " +
              "SchemaUpdate parameters: haltonerror = true, format= true, delimiter and outputfilename" +
              " either update hibernate jar or don't used the involved parameters", e );
        } catch (IllegalAccessException e) {
          log.error( "Error during DDL export, this version of hibernate doesn't support following " +
              "SchemaUpdate parameters: haltonerror = true, format= true, delimiter and outputfilename" +
              " either update hibernate jar or don't used the involved parameters", e );
        }
      }

    } else {
      ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
      builder.applySettings(configuration.getProperties());
      ServiceRegistry serviceRegistry = builder.buildServiceRegistry();
      serviceRegistry.getService( JdbcServices.class );
      SchemaExport export = new SchemaExport(serviceRegistry, configuration);
      if (null != outputFileName) {
        export.setOutputFile(new File(getOutputDirectory(),
            outputFileName).toString());
View Full Code Here

   * @deprecated Use {@link #buildSessionFactory(ServiceRegistry)} instead
   */
  public SessionFactory buildSessionFactory() throws HibernateException {
    Environment.verifyProperties( properties );
    ConfigurationHelper.resolvePlaceHolders( properties );
    final ServiceRegistry serviceRegistry =  new ServiceRegistryBuilder()
        .applySettings( properties )
        .buildServiceRegistry();
    setSessionFactoryObserver(
        new SessionFactoryObserver() {
          @Override
View Full Code Here

        // Fetch and pre-process the Hibernate mapping descriptors.
        loadHibernateDescriptors(hbmConfig);

        // Initialize the Hibernate session factory.
        ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(hbmConfig.getProperties()).buildServiceRegistry();
        SessionFactory factory = hbmConfig.buildSessionFactory(serviceRegistry);
        hibernateSessionFactoryProvider.setSessionFactory(factory);

        // Synchronize the database schema.
        if (databaseAutoSynchronizer != null) {
View Full Code Here

TOP

Related Classes of org.hibernate.service.ServiceRegistryBuilder

Copyright © 2018 www.massapicom. 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.