Java 类org.hibernate.tool.hbm2ddl.Target 实例源码

项目:pluggable    文件:Hello.java   
public static void main(String[] args) {
        Configuration hello =new Configuration();

        Properties properties = new Properties();
        properties.setProperty(Environment.DIALECT, MySQL5Dialect.class.getName());
        hello.setProperties(properties);
        hello.addAnnotatedClass(Hello.class);
        hello.addAnnotatedClass(Hello1.class);
        SchemaExport schemaExport = new SchemaExport(hello);
        schemaExport.setDelimiter(";");
//        schemaExport.setOutputFile(String.format("%s_%s.%s ", new Object[] {"ddl", dialect.name().toLowerCase(), "sql" }));
         boolean consolePrint = true;
         boolean exportInDatabase = false;
//         schemaExport.create(consolePrint, exportInDatabase);
        schemaExport.create(Target.SCRIPT);

    }
项目:corporate-game-share    文件:SchemaTranslator.java   
@Test
public void testDbSchema() {
    MetadataSources metadata = new MetadataSources(new StandardServiceRegistryBuilder()
                    .applySetting("hibernate.dialect", "org.hibernate.dialect.H2Dialect").build());

    metadata.addAnnotatedClass(ConsoleEntity.class);
    metadata.addAnnotatedClass(GameEntity.class);
    metadata.addAnnotatedClass(UserEntity.class);
    metadata.addAnnotatedClass(RoleEntity.class);
    metadata.addAnnotatedClass(LibraryEntity.class);
    metadata.addAnnotatedClass(BorrowEntity.class);

    SchemaExport export = new SchemaExport((MetadataImplementor) metadata.buildMetadata());
    export.create(Target.SCRIPT);
}
项目:finances    文件:HibernateDaoContext.java   
public static void main(String[] args) {
        try {
            DriverService driverService = CONNECTION_CONFIG.loadDriver();
            HibernateDaoContext context = new HibernateDaoContext(driverService, ApplicationConfig.CONFIG);
//            Stream.of(context.schemaCreationScript()).forEach(System.out::println);
            new SchemaUpdate(context.configuration).execute(Target.SCRIPT);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
项目: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());
}