Java 类org.hibernate.tool.hbm2ddl.SchemaExport.Type 实例源码

项目:webapp-base    文件:SchemaController.java   
@RequestMapping("/admin/schema")
public void exportSchema(final Model model) throws IOException {

    final SchemaExport export = new SchemaExport(localSessionFactoryBuilder);
    final File f = Files.createTempFile(null, null).toFile();
    export.setOutputFile(f.getCanonicalPath());
    export.execute(Target.SCRIPT, Type.CREATE);

    model.addAttribute("ddl", FileUtils.readFileToString(f));
    model.addAttribute("file", f.getCanonicalPath());
}
项目:webapp-base    文件:PersistenceConfigTest.java   
@Test
public void exportSchemaShouldCreateSqlFile() {
    final SchemaExport export = new SchemaExport(localSessionFactoryBuilder);
    export.setOutputFile(OUTPUT_FILE_NAME);
    export.execute(Target.SCRIPT, Type.CREATE);

    final File f = new File(OUTPUT_FILE_NAME);
    assertTrue(f.exists());
}