Package org.hibernate.tool.hbm2ddl

Examples of org.hibernate.tool.hbm2ddl.SchemaUpdate.execute()


  }

  @SuppressWarnings("unchecked")
  private void initializeDatabase() throws HttpException {
    SchemaUpdate su = new SchemaUpdate(Hiber.getConfiguration());
    su.execute(false, true);

    Session s = Hiber.session();

    List<Exception> exceptions = su.getExceptions();
    if (exceptions.size() > 0) {
View Full Code Here


     */
    public void updateSchema(Properties properties) throws EvolizerException {
        try {
            Configuration configuration = configureDataBaseConnection(properties);
            SchemaUpdate updater = new SchemaUpdate(configuration);
            updater.execute(false, true);
        } catch (HibernateException he) {
            throw new EvolizerException(he);
        }
    }

View Full Code Here

          }
         
          if (mode == Mode.UPDATE)
          {
              SchemaUpdate update = new SchemaUpdate(configuration, settings);
              update.execute(true, exec);
          }
          else
          {
              SchemaExport export = exec ? new SchemaExport(configuration, settings) :
                      new SchemaExport(configuration);
View Full Code Here

    Statement stat = conn.createStatement();
    stat.execute("ALTER TABLE \"SB\".\"Team\" DROP COLUMN name ");
   
    // update schema
    SchemaUpdate su = new SchemaUpdate(getCfg());
    su.execute(true,true);
   
    // we can run schema validation. Note that in the setUp method a *wrong* table
    // has been created with different column names
    // if schema validator chooses the bad db schema, then the testcase will fail (exception)
    SchemaValidator sv = new SchemaValidator(getCfg());
View Full Code Here

    stat.execute("CREATE VIEW \"SB\".\"TeamView\" AS SELECT \"iD\",name, name as duplicatedname FROM \"SB\".\"Team\"");
   

    // update schema, here should do nothing
    SchemaUpdate su = new SchemaUpdate(getCfg());
    su.execute(true,true);
   
    // we can run schema validation.
    // if schema validator chooses the bad db schema, then the testcase will fail (exception)
    SchemaValidator sv = new SchemaValidator(getCfg());
    sv.validate();
View Full Code Here

    Statement stat = conn.createStatement();
    stat.execute("ALTER TABLE \"SB\".\"TEAM\" DROP COLUMN xname ");
   
    // update schema
    SchemaUpdate su = new SchemaUpdate(getCfg());
    su.execute(true,true);
   
    // we can run schema validation. Note that in the setUp method a *wrong* table
    // has been created with different column names
    // if schema validator chooses the bad db schema, then the testcase will fail (exception)
    SchemaValidator sv = new SchemaValidator(getCfg());
View Full Code Here

    if (schemaUpdate) {
      SchemaUpdate update = new SchemaUpdate(serviceRegistry, 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 {
       
View Full Code Here

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

            executeSQLScript(ormConf,dc);
    }
    else if(ORMConfiguration.DBCREATE_UPDATE==ormConf.getDbCreate()) {
      SchemaUpdate update = new SchemaUpdate(configuration);
            update.setHaltOnError(true);
            update.execute(false, true);
            printError(data,update.getExceptions(),false);
        }
  }

  private static void printError(SessionFactoryData data, List<Exception> exceptions,boolean throwException) throws PageException {
View Full Code Here

  {
    final Ejb3Configuration cfg = new Ejb3Configuration();
    cfg.configure(persistenceUnitName, configOverwrites);
    final SchemaUpdate schemaUpdate = new SchemaUpdate(cfg.getHibernateConfiguration());
    schemaUpdate.setOutputFile("schema.sql");
    schemaUpdate.execute(true, true);
  }

  @Override
  public void dropTables(String persistenceUnitName, final Map<String, Object> configOverwrites)
  {
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.