Hibernate ORM SchemaExport - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Hibernate ORM SchemaExport class.

This code example shows how to use the following methods:drop, setOutputFile
	@Override 
	public void dropTables(String persistenceUnitName, final Map<String, Object> configOverwrites)
	{ 
		final Ejb3Configuration cfg = new Ejb3Configuration();
		cfg.configure(persistenceUnitName, configOverwrites);
		final SchemaExport schemaExport = new SchemaExport(cfg.getHibernateConfiguration());
		schemaExport.setOutputFile("schema.sql");
		schemaExport.drop(true, true);
	} 
 
	@SuppressWarnings("deprecation") 
	@Override 
	public Connection getConnection(EntityManager em)
	{ 
		return ((HibernateEntityManager) em).getSession().connection();
	} 
} 
6
CodeRank
This code example shows how to use the following methods:create, setDelimiter, setFormat, setOutputFile
    public void afterPropertiesSet() throws Exception {
        this.createSchema();
    } 
 
    protected void exportSchema() { 
        schema.setOutputFile("target/schema.sql");
 
        schema.setFormat(true);
        schema.setDelimiter(";");
        schema.create(true, false);
    } 
 
    protected abstract void createSchema(); 
} 
6
CodeRank
This code example shows how to use the following methods:create, setDelimiter
    public static void main(String[] args) {
		Ejb3Configuration cfg = new Ejb3Configuration();
		HashMap<String, String> props = new HashMap<String, String>();
		props.put("hibernate.format_sql", "true");
		Ejb3Configuration configured = cfg.configure("slipp.qna", props);
		SchemaExport se = new SchemaExport(configured.getHibernateConfiguration());
		se.setDelimiter(";");
		se.create(true, false);
	} 
} 
6
CodeRank
This code example shows how to use the following methods:execute, setDelimiter, setOutputFile
   * @param dialect - Database dialect to use 
   */ 
  public void generateSQL(Dialect dialect) {
    configuration.setProperty("hibernate.dialect", dialect.getDialectClass());
 
    SchemaExport export = new SchemaExport(configuration);
    export.setDelimiter(";");
    String outputFile = this.outputDir + File.separator + "ddl_" + dialect.name().toLowerCase() + ".sql";
    export.setOutputFile(outputFile);
    export.execute(false, false, false, !updateSchema);
  } 
 
  /** 
   * Run the schema creation script 
   * 
   * @param jdbcUrl  - the jdbc url for the database in which to run the script 
   * @param dialect- the sql dialect for the database 
   * @param username - the username for the database 
   * @param password - the password to use 
   */ 
6
CodeRank
This code example shows how to use the following methods:create, setFormat, setOutputFile
public class CreateDataBaseTableByHibernateConfigFile { 
	 
	 
	public static void main(String[] args) {
		Configuration configuration = new Configuration().configure().setNamingStrategy(new ImprovedNamingStrategy());
		SchemaExport export = new SchemaExport(configuration);
		 
		export.setFormat(false);
		export.setOutputFile("src/test/resources/data/h2/create-table-new.sql");
		export.create(true, false);
	} 
	 
} 
5
CodeRank
This code example shows how to use the following methods:create, setFormat, setOutputFile
public class CreateTestInitializeDataBaseSqlFile { 
	 
	public static void main(String[] args) {
		 
		Configuration configuration = new Configuration().configure().setNamingStrategy(new ImprovedNamingStrategy());
		SchemaExport export = new SchemaExport(configuration);
		 
		export.setFormat(false);
		export.setOutputFile("src/test/resources/h2schma.sql");
		export.create(true, false);
	} 
} 
5
CodeRank
This code example shows how to use the following methods:execute, setDelimiter, setOutputFile
    if (!patchSchema.exists()) {
      patchSchema.getParentFile().mkdirs();
      patchSchema.createNewFile();
    } 
     
    SchemaExport export = new SchemaExport(cfg);
    export.setDelimiter(";");
    export.setOutputFile(patchSchema.getAbsolutePath());
    // Generates alter table drops which should be removed at version 0 
    export.execute(true, false, false, false);
 
    log.info("Schema export complete. Results in '{}'",patchSchema.getAbsolutePath());
  } 
 
  /** 
   * @param args Command line args (ignored) 
   * @throws Exception If something goes wrong 
   */ 
  public static void main(String[] args) throws Exception {
    // The target revision based on the current domain model 
4
CodeRank
This code example shows how to use the following methods:
 
        DataSource dataSource = ctx.getBean(DataSource.class); 
        LocalSessionFactoryBean factoryBean = ctx.getBean(LocalSessionFactoryBean.class); 
        Configuration configuration = factoryBean.getConfiguration(); 
 
        SchemaExport export = new SchemaExport(configuration, dataSource.getConnection()).setDelimiter(";"); 
 
        boolean printDDLToConsole = true; 
        if (args.length > 0) { 
            String outputFile = args[0]; 
            System.out.println("Writing out create statements to " + outputFile); 
            printDDLToConsole = false; 
            export.setOutputFile(outputFile); 
        } 
        export.execute(printDDLToConsole, false, false, true); 
 
        printDDLToConsole = true; 
        if (args.length > 1) { 
            String outputFile = args[1]; 
            System.out.println("Writing out drop statements to " + outputFile); 
4
CodeRank
This code example shows how to use the following methods:
 
	@Override 
	protected void cleanupTest() throws Exception {
		Connection conn = cp.getConnection();
		try { 
			new SchemaExport( configuration(), conn ).drop( false, true );
		} 
		finally { 
			if ( conn != null ) {
				try { 
					cp.closeConnection( conn );
				} 
				catch( Throwable ignore ) {
				} 
			} 
		} 
		super.cleanupTest(); 
	} 
} 
4
CodeRank
This code example shows how to use the following methods:create, setOutputFile
	    Map jpaPropertyMap = entityManagerFactory.getJpaPropertyMap(); 
 
	    @SuppressWarnings("deprecation") 
		org.hibernate.cfg.Configuration configuration = new Ejb3Configuration().configure( persistenceUnitInfo, jpaPropertyMap ).getHibernateConfiguration(); 
 
	    SchemaExport schema = new SchemaExport(configuration); 
	    schema.setOutputFile("c:/schema.sql"); 
	    schema.create(true, false); 
 
		 
	} 
 
} 
4
CodeRank
See Code Examples for Hibernate ORM SchemaExport Methods: