Package org.hibernate.tool.hbm2ddl

Examples of org.hibernate.tool.hbm2ddl.SchemaExport


    SchemaExport export = new SchemaExport( cfg );
    export.create( true, true );
  }

  protected void runSchemaDrop() {
    SchemaExport export = new SchemaExport( cfg );
    export.drop( true, true );
  }
View Full Code Here


        properties
    );


    if ( settings.isAutoCreateSchema() ) {
      new SchemaExport( serviceRegistry, cfg )
          .setImportSqlCommandExtractor( serviceRegistry.getService( ImportSqlCommandExtractor.class ) )
          .create( false, true );
    }
    if ( settings.isAutoUpdateSchema() ) {
      new SchemaUpdate( serviceRegistry, cfg ).execute( false, true );
    }
    if ( settings.isAutoValidateSchema() ) {
      new SchemaValidator( serviceRegistry, cfg ).validate();
    }
    if ( settings.isAutoDropSchema() ) {
      schemaExport = new SchemaExport( serviceRegistry, cfg )
          .setImportSqlCommandExtractor( serviceRegistry.getService( ImportSqlCommandExtractor.class ) );
    }

    currentSessionContext = buildCurrentSessionContext();
View Full Code Here

    if ( debugEnabled ) {
      LOG.debug("Instantiated session factory");
    }

    if ( settings.isAutoCreateSchema() ) {
      new SchemaExport( metadata )
          .setImportSqlCommandExtractor( serviceRegistry.getService( ImportSqlCommandExtractor.class ) )
          .create( false, true );
    }

    if ( settings.isAutoDropSchema() ) {
      schemaExport = new SchemaExport( metadata )
          .setImportSqlCommandExtractor( serviceRegistry.getService( ImportSqlCommandExtractor.class ) );
    }

    currentSessionContext = buildCurrentSessionContext();
View Full Code Here

    // get the hibernate Configuration
    Configuration configuration = AntHelper.getConfiguration(cfg,properties);

    JbpmSchema jbpmSchema = new JbpmSchema(configuration);

    SchemaExport schemaExport = new SchemaExport(configuration);
    if (output!=null) schemaExport.setOutputFile(output);
    if (delimiter!=null) schemaExport.setDelimiter(delimiter);

    StringTokenizer tokenizer = new StringTokenizer(actions, ",");
    while (tokenizer.hasMoreTokens()) {
      String action = tokenizer.nextToken();

      if ("drop".equalsIgnoreCase(action)) {
        schemaExport.drop(!quiet, !text);

      } else if ("create".equalsIgnoreCase(action)) {
        schemaExport.create(!quiet, !text);
       
      } else if ("clean".equalsIgnoreCase(action)) {
        jbpmSchema.cleanSchema();
      }
    }
View Full Code Here

    try {
      new File(dir).mkdirs();
      saveSqlScript(dir+"/"+prefix+".drop.sql", getDropSql());
      saveSqlScript(dir+"/"+prefix+".create.sql", getCreateSql());
      saveSqlScript(dir+"/"+prefix+".clean.sql", getCleanSql());
      new SchemaExport(configuration)
        .setDelimiter(getSqlDelimiter())
        .setOutputFile(dir+"/"+prefix+".drop.create.sql")
        .create(true, false);
    } catch (Exception e) {
      throw new JbpmException("couldn't generate scripts", e);
View Full Code Here

  }

  public synchronized SchemaExport getSchemaExport() {
    if (schemaExport==null) {
      log.debug("creating schema export");
      schemaExport = new SchemaExport(getConfiguration());
    }
    return schemaExport;
  }
View Full Code Here

  public static Configuration getConfiguration(SessionFactory sessionFactory) {
    return (Configuration) configurations.get(sessionFactory);
  }
 
  public static SchemaExport createSchemaExport(SessionFactory sessionFactory) {
    return new SchemaExport(getConfiguration(sessionFactory));
  }
View Full Code Here

                        .getResources("classpath*:mappings.hbm.xml");
                for (Resource resource : resources) {
                    cfg.addInputStream(resource.getInputStream());
                }

                SchemaExport export = new SchemaExport(cfg);
                export.drop(true, true);
                export.create(true, true);
            } catch (Exception e) {
                throw new BeanInitializationException(null, e);
            }
        }
        return bean;
View Full Code Here

      Class<?> c = Class.forName(className);
      configuration.addAnnotatedClass(c);
    }
   
    configuration.setProperty("hibernate.dialect", dialectName);
    SchemaExport exporter = new SchemaExport(configuration);
    exporter.setDelimiter(";");
    exporter.setOutputFile(fileName);
   
    boolean script = true;
    boolean export = false;
    boolean justDrop = false;
    boolean justCreate = false;
    exporter.execute(script, export, justDrop, justCreate);
  }
View Full Code Here

        configuration.setProperty("hibernate.dialect", this.dialect);
        configuration.buildMappings();
       
        final Connection connection = DataSourceUtils.getConnection(this.dataSource);
        try {
            final SchemaExport exporter = new SchemaExport(configuration, connection);
            exporter.setFormat(false);
            if (outputFile != null) {
                exporter.setOutputFile(outputFile);
            }
           
            exporter.execute(true, export, !create, !drop);
        }
        finally {
            DataSourceUtils.releaseConnection(connection, this.dataSource);
        }
    }
View Full Code Here

TOP

Related Classes of org.hibernate.tool.hbm2ddl.SchemaExport

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.