Package org.hibernate.tool.hbm2ddl

Examples of org.hibernate.tool.hbm2ddl.SchemaUpdate


    Connection conn = session.connection();
    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


    Configuration v1cfg = new Configuration();
    v1cfg.addResource( resource1 );
    new SchemaExport( v1cfg ).execute( false, true, true, false );

    SchemaUpdate v1schemaUpdate = new SchemaUpdate( v1cfg );
    v1schemaUpdate.execute( true, true );

    assertEquals( 0, v1schemaUpdate.getExceptions().size() );

    Configuration v2cfg = new Configuration();
    v2cfg.addResource( resource2 );

    SchemaUpdate v2schemaUpdate = new SchemaUpdate( v2cfg );
    v2schemaUpdate.execute( true, true );
    assertEquals( 0, v2schemaUpdate.getExceptions().size() );
   
    new SchemaExport( v2cfg ).drop( false, true );

  }
View Full Code Here

  private static final Log logger = LogFactory.getLog(SchemaUpdater.class);

  public static void main(String[] args) {
    Configuration config = new Configuration();
    config.configure();
    SchemaUpdate su = new SchemaUpdate(config);
    su.execute(true, true);
  }
View Full Code Here


  private static void update() {
    Configuration config = new Configuration();
    config.configure();
    SchemaUpdate su = new SchemaUpdate(config);
    su.execute(true, true);
  }
View Full Code Here

        }
    }

    private void updateDatabase(Configuration cfg) {
        try {
            new SchemaUpdate(cfg).execute(false, true);
        } catch (HibernateException e) {
            log.error("DB Error: " + UPDATE_ERROR + " !", e);
            throw new RuntimeException("DB Error: " + UPDATE_ERROR + " ! " + e.getMessage());
        }
    }
View Full Code Here

    if ( settings.isAutoCreateSchema() ) {
      new SchemaExport( cfg, settings ).create( false, true );
    }
    if ( settings.isAutoUpdateSchema() ) {
      new SchemaUpdate( cfg, settings ).execute( false, true );
    }
    if ( settings.isAutoValidateSchema() ) {
      new SchemaValidator( cfg, settings ).validate();
    }
    if ( settings.isAutoDropSchema() ) {
View Full Code Here

        }
    }

    private void updateDatabase(Configuration cfg) {
        try {
            new SchemaUpdate(cfg).execute(false, true);
        } catch (HibernateException e) {
            log.error("DB Error: " + UPDATE_ERROR + " !", e);
            throw new RuntimeException("DB Error: " + UPDATE_ERROR + " ! " + e.getMessage());
        }
    }
View Full Code Here

    }
  }

  @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) {
      for (Exception exception : exceptions) {
        exception.printStackTrace();
      }
      throw new UserException("Errors in schema generation.");
View Full Code Here

    if ( settings.isAutoCreateSchema() ) {
      new SchemaExport( serviceRegistry, cfg ).create( false, true );
    }
    if ( settings.isAutoUpdateSchema() ) {
      new SchemaUpdate( serviceRegistry, cfg ).execute( false, true );
    }
    if ( settings.isAutoValidateSchema() ) {
      new SchemaValidator( serviceRegistry, cfg ).validate();
    }
    if ( settings.isAutoDropSchema() ) {
View Full Code Here

     * @throws EvolizerException
     */
    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

TOP

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

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.