@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()); }
@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()); }