當前位置: 首頁>>代碼示例>>Java>>正文


Java SchemaExport.setOutputFile方法代碼示例

本文整理匯總了Java中org.hibernate.tool.hbm2ddl.SchemaExport.setOutputFile方法的典型用法代碼示例。如果您正苦於以下問題:Java SchemaExport.setOutputFile方法的具體用法?Java SchemaExport.setOutputFile怎麽用?Java SchemaExport.setOutputFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.hibernate.tool.hbm2ddl.SchemaExport的用法示例。


在下文中一共展示了SchemaExport.setOutputFile方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generateDDL

import org.hibernate.tool.hbm2ddl.SchemaExport; //導入方法依賴的package包/類
private void generateDDL() throws Exception {
    final MetadataImplementor md = createMetaData();
    final SchemaExport export = new SchemaExport(md);

    // drop
    {
        export.setDelimiter(";");
        export.setOutputFile(getRefPath() + "/db-drop.sql");
        export.setFormat(true);
        export.execute(true, false, true, false);
    }
    // create
    {
        export.setDelimiter(";");
        export.setOutputFile(getRefPath() + "/db-create.sql");
        export.setFormat(true);
        export.execute(true, false, false, true);
    }
}
 
開發者ID:shared-vd,項目名稱:tipi-engine,代碼行數:20,代碼來源:TipiDDLGeneratorTest.java

示例2: outputDdl

import org.hibernate.tool.hbm2ddl.SchemaExport; //導入方法依賴的package包/類
private void outputDdl(String packageName, String dialect, String fileName) {
    LocalSessionFactoryBean sfBean = sfBean(packageName, dialect);
    StandardServiceRegistry serviceRegistry = sfBean.getConfiguration().getStandardServiceRegistryBuilder().build();
    try {
        String outputFile = OutputRoot + fileName;
        Files.deleteIfExists(Paths.get(outputFile));
        MetadataImplementor metadata = metadata(sfBean, serviceRegistry);
        
        SchemaExport export = new SchemaExport();
        export.setDelimiter(";");
        export.setFormat(FormatSql);
        export.setOutputFile(outputFile);
        export.create(EnumSet.of(TargetType.SCRIPT), metadata);
    } catch (Exception e) {
        throw new InvocationException(e);
    } finally {
        StandardServiceRegistryBuilder.destroy( serviceRegistry );
    }
}
 
開發者ID:jkazama,項目名稱:sample-boot-micro,代碼行數:20,代碼來源:DdlExporter.java

示例3: generateDatabase

import org.hibernate.tool.hbm2ddl.SchemaExport; //導入方法依賴的package包/類
/**
 * Generate database schema and initial data for a defined dialect
 */
public static void generateDatabase(String dialect) throws IOException {
	// Configure Hibernate
	log.info("Exporting Database Schema...");
	String dbSchema = EnvironmentDetector.getUserHome() + "/schema.sql";
	Configuration cfg = getConfiguration().configure();
	cfg.setProperty("hibernate.dialect", dialect);
	SchemaExport se = new SchemaExport(cfg);
	se.setOutputFile(dbSchema);
	se.setDelimiter(";");
	se.setFormat(false);
	se.create(false, false);
	log.info("Database Schema exported to {}", dbSchema);

	String initialData = new File("").getAbsolutePath() + "/src/main/resources/default.sql";
	log.info("Exporting Initial Data from '{}'...", initialData);
	String initData = EnvironmentDetector.getUserHome() + "/data.sql";
	FileInputStream fis = new FileInputStream(initialData);
	String ret = DatabaseDialectAdapter.dialectAdapter(fis, dialect);
	FileWriter fw = new FileWriter(initData);
	IOUtils.write(ret, fw);
	fw.flush();
	fw.close();
	log.info("Initial Data exported to {}", initData);
}
 
開發者ID:openkm,項目名稱:document-management-system,代碼行數:28,代碼來源:HibernateUtil.java

示例4: main

import org.hibernate.tool.hbm2ddl.SchemaExport; //導入方法依賴的package包/類
/**
 * Only for testing purposes
 */
public static void main(String[] args) throws Exception {
	log.info("Generate database schema & initial data");
	HibernateUtil.generateDatabase("org.hibernate.dialect.Oracle10gDialect");
	Configuration cfg = new Configuration();

	// Add annotated beans
	cfg.addAnnotatedClass(NodeFolder.class);

	// Configure Hibernate
	cfg.setProperty("hibernate.dialect", Config.HIBERNATE_DIALECT);
	cfg.setProperty("hibernate.hbm2ddl.auto", "create");

	SchemaExport se = new SchemaExport(cfg);
	se.setOutputFile("/home/pavila/export.sql");
	se.setDelimiter(";");
	se.setFormat(false);
	se.create(false, false);
}
 
開發者ID:openkm,項目名稱:document-management-system,代碼行數:22,代碼來源:Test.java

示例5: createSQLSchema

import org.hibernate.tool.hbm2ddl.SchemaExport; //導入方法依賴的package包/類
private void createSQLSchema(String fileName, String dialect) throws Exception {
        org.hibernate.cfg.Configuration configuration = new Configuration();
        configuration.setNamingStrategy(new MidPointNamingStrategy());
        configuration.setProperties(sessionFactory.getHibernateProperties());
        sessionFactory.getHibernateProperties().setProperty("hibernate.dialect", dialect);

        System.out.println("Dialect: " + sessionFactory.getHibernateProperties().getProperty("hibernate.dialect"));

        addAnnotatedClasses("com.evolveum.midpoint.repo.sql.data.common", configuration);
        addAnnotatedClasses("com.evolveum.midpoint.repo.sql.data.common.container", configuration);
        addAnnotatedClasses("com.evolveum.midpoint.repo.sql.data.common.any", configuration);
        addAnnotatedClasses("com.evolveum.midpoint.repo.sql.data.common.embedded", configuration);
        addAnnotatedClasses("com.evolveum.midpoint.repo.sql.data.common.enums", configuration);
        addAnnotatedClasses("com.evolveum.midpoint.repo.sql.data.common.id", configuration);
        addAnnotatedClasses("com.evolveum.midpoint.repo.sql.data.common.other", configuration);
        addAnnotatedClasses("com.evolveum.midpoint.repo.sql.data.common.type", configuration);
        addAnnotatedClasses("com.evolveum.midpoint.repo.sql.data.audit", configuration);
//        addAnnotatedClasses("com.evolveum.midpoint.repo.sql.data.poc", configuration);

        configuration.addPackage("com.evolveum.midpoint.repo.sql.type");

        SchemaExport export = new SchemaExport(configuration);
        export.setOutputFile(fileName);
        export.setDelimiter(";");
        export.execute(true, false, false, true);
    }
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:27,代碼來源:SpringApplicationContextTest.java

示例6: export

import org.hibernate.tool.hbm2ddl.SchemaExport; //導入方法依賴的package包/類
protected void export(Class<? extends Dialect> dialect, String app_key, Configuration configuration, boolean create, boolean drop) {
    Assert.notNull(dialect, "dialect is invalid [null]");
    Assert.notNull(app_key, "app_key is invalid [null]");
    Assert.notNull(configuration, "configuration is invalid [null]");
    
    SchemaExport schemaExport = new SchemaExport(configuration);
    schemaExport.setDelimiter(";");
    schemaExport.setFormat(true);

    if (create) {
        // Generate create script
        schemaExport.setOutputFile(String.format("target/%s_ddl_%s_create.sql", app_key, dialect.getSimpleName()));
        schemaExport.execute(true, false, false, true);
    }

    if (drop) {
        // Generate drop script
        schemaExport.setOutputFile(String.format("target/%s_ddl_%s_drop.sql", app_key, dialect.getSimpleName()));
        schemaExport.execute(true, false, true, false);
    }
}
 
開發者ID:bartgerard,項目名稱:ubrew_v0.1,代碼行數:22,代碼來源:SchemaExporterOld.java

示例7: export

import org.hibernate.tool.hbm2ddl.SchemaExport; //導入方法依賴的package包/類
protected void export(Class<? extends Dialect> dialect, String app_key, MetadataSources metadata, boolean create, boolean drop) {
    Assert.notNull(dialect, "dialect is invalid [null]");
    Assert.notNull(app_key, "app_key is invalid [null]");
    Assert.notNull(metadata, "metadata is invalid [null]");

    SchemaExport schemaExport = new SchemaExport((MetadataImplementor) metadata.buildMetadata());
    schemaExport.setDelimiter(";");
    schemaExport.setFormat(true);

    if (create) {
        // Generate create script
        schemaExport.setOutputFile(String.format("target/%s_ddl_%s_create.sql", app_key, dialect.getSimpleName()));
        schemaExport.execute(true, false, false, true);
    }

    if (drop) {
        // Generate drop script
        schemaExport.setOutputFile(String.format("target/%s_ddl_%s_drop.sql", app_key, dialect.getSimpleName()));
        schemaExport.execute(true, false, true, false);
    }
}
 
開發者ID:bartgerard,項目名稱:ubrew_v0.1,代碼行數:22,代碼來源:SchemaExporter.java

示例8: generate

import org.hibernate.tool.hbm2ddl.SchemaExport; //導入方法依賴的package包/類
/**
 * Method that actually creates the file.
 *
 * @param dbDialect to use
 */
private void generate(Dialect dialect) {

        StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder();
        ssrb.applySetting("hibernate.dialect", dialect.getDialectClass());
        StandardServiceRegistry standardServiceRegistry = ssrb.build();

        MetadataSources metadataSources = new MetadataSources(standardServiceRegistry);
        for (Class clzz : jpaClasses) {
                metadataSources.addAnnotatedClass(clzz);
        }

        Metadata metadata = metadataSources.buildMetadata();

        SchemaExport export = new SchemaExport();

        export.setDelimiter(";");
        export.setOutputFile(dialect.name().toLowerCase() + ".ddl");
        //export.execute(true, false, false, true);
        export.execute(EnumSet.of(TargetType.SCRIPT), Action.BOTH, metadata);
}
 
開發者ID:apache,項目名稱:juddi,代碼行數:26,代碼來源:App.java

示例9: exportDatabaseSchema

import org.hibernate.tool.hbm2ddl.SchemaExport; //導入方法依賴的package包/類
/**
 * Controller method to download a ddl.
 */
@Deprecated
@SuppressWarnings({"unchecked", "rawtypes"})
@RequestMapping(value = "ddl", method = RequestMethod.GET)
public void exportDatabaseSchema(HttpServletRequest request, HttpServletResponse response, Model uiModel) {
	PersistenceUnitInfo persistenceUnitInfo = getEntityManagerFactory().getPersistenceUnitInfo();

	Map jpaPropertyMap = getEntityManagerFactory().getJpaPropertyMap();
	jpaPropertyMap.put("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
	Configuration configuration = new Ejb3Configuration().configure(persistenceUnitInfo, jpaPropertyMap).getHibernateConfiguration();

	SchemaExport schema = new SchemaExport(configuration);
	schema.setFormat(true);
	schema.setDelimiter(";");
	schema.setOutputFile("/tmp/schema.sql");
	schema.create(false, false);
}
 
開發者ID:tamerman,項目名稱:mobile-starting-framework,代碼行數:20,代碼來源:HomeController.java

示例10: createSQLSchema

import org.hibernate.tool.hbm2ddl.SchemaExport; //導入方法依賴的package包/類
private void createSQLSchema(String fileName) throws Exception {
    org.hibernate.cfg.Configuration configuration = new Configuration();
    Properties properties = new Properties();
    properties.putAll(sessionFactoryBean.getJpaPropertyMap());
    configuration.setProperties(properties);
    configuration.setNamingStrategy(new GizmoNamingStrategy());

    System.out.println("Dialect: " + properties.getProperty("hibernate.dialect"));

    addAnnotatedClasses("sk.lazyman.gizmo.data", configuration);

    SchemaExport export = new SchemaExport(configuration);
    export.setOutputFile(fileName);
    export.setDelimiter(";");
    export.execute(true, false, false, true);
}
 
開發者ID:Evolveum,項目名稱:gizmo-v3,代碼行數:17,代碼來源:SpringApplicationContextTest.java

示例11: generateCreate

import org.hibernate.tool.hbm2ddl.SchemaExport; //導入方法依賴的package包/類
@Test
public void generateCreate() throws ClassNotFoundException {
	final long now = System.currentTimeMillis() - LAST_MODIFIED_PRECISION;
	final Configuration cfg = new Configuration();
	cfg.setProperty("hibernate.hbm2ddl.auto", "create");
	cfg.setProperty("hibernate.dialect", ORACLE_DIALECT);
	cfg.setNamingStrategy(new MyNamingStrategy());

	for (final String className : findEntities()) {
		cfg.addAnnotatedClass(Class.forName(className));
	}

	final SchemaExport export = new SchemaExport(cfg);
	export.setDelimiter(";");
	export.setOutputFile(CREATE_FILE_NAME);
	export.execute(true, false, false, true);
	File file = new File(CREATE_FILE_NAME);
	assertThat(file.lastModified()).as("the file should be generated").isGreaterThan(now);
}
 
開發者ID:ValtechTechno,項目名稱:dbdiff,代碼行數:20,代碼來源:SchemaFromScratchTest.java

示例12: main

import org.hibernate.tool.hbm2ddl.SchemaExport; //導入方法依賴的package包/類
public static void main(String[] args){

        String file = "camping-db-creation.sql";
        new File(file).delete();

        MetadataSources metadata = new MetadataSources(
                new StandardServiceRegistryBuilder().configure().build());

        SchemaExport export = new SchemaExport();
        export.setOutputFile(file);
        export.setDelimiter(";");
        export.setFormat(true);
        export.execute(EnumSet.of(TargetType.SCRIPT), SchemaExport.Action.CREATE, metadata.buildMetadata());
    }
 
開發者ID:Moccko,項目名稱:campingsimulator2017,代碼行數:15,代碼來源:DBCreation.java

示例13: generateCreateAnUpdateDDL

import org.hibernate.tool.hbm2ddl.SchemaExport; //導入方法依賴的package包/類
@Test
public void generateCreateAnUpdateDDL() throws IOException {
    logger.debug("Generate create and update DDL");
    
    EntityManagerFactoryImpl emf = (EntityManagerFactoryImpl) lcemfb.getNativeEntityManagerFactory();
    SessionFactoryImpl sf = emf.getSessionFactory();
    SessionFactoryServiceRegistryImpl serviceRegistry = (SessionFactoryServiceRegistryImpl) sf.getServiceRegistry();
    Configuration cfg = null;
    
    try {
        Field field = SessionFactoryServiceRegistryImpl.class.getDeclaredField("configuration");
        field.setAccessible(true);
        cfg = (Configuration) field.get(serviceRegistry);
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
        throw new RuntimeException(e);
    }
    
    Files.createDirectories(Paths.get("target/db/migration/"));
    
    SchemaUpdate update = new SchemaUpdate(serviceRegistry, cfg);
    update.setDelimiter(";");
    update.setOutputFile("target/db/migration/Vx__yy_zz.sql");
    update.execute(false, false);
    
    SchemaExport export = new SchemaExport(serviceRegistry, cfg);
    export.setDelimiter(";");
    export.setOutputFile("target/db/migration/create.sql");
    export.execute(false, false, false, true);     
}
 
開發者ID:box,項目名稱:mojito,代碼行數:30,代碼來源:DDLGenerator.java

示例14: configureAndGenerate

import org.hibernate.tool.hbm2ddl.SchemaExport; //導入方法依賴的package包/類
/**
 * Method to configure necessary hibernate properties and generate DDL for a supplied configuration
 * @param dialectName Which hibernate dialect should be used
 * @param destinationDirectory The output directory
 * @param outputFileName The output filename
 * @param configuration The hibernate configuration setup with the appropriate schema objects
 */
private void configureAndGenerate(final String dialectName, final String destinationDirectory, final String outputFileName,
		final Configuration configuration)
{
	final Properties dialect = new Properties();
	dialect.setProperty("hibernate.dialect", dialectName);
	configuration.addProperties(dialect);

	final SchemaExport se = new SchemaExport(configuration);
	se.setOutputFile(destinationDirectory + outputFileName);
	se.setDelimiter(";\n");
	se.create(true, false);
}
 
開發者ID:danielhams,項目名稱:mad-java,代碼行數:20,代碼來源:GeneratorHelper.java

示例15: generate

import org.hibernate.tool.hbm2ddl.SchemaExport; //導入方法依賴的package包/類
private void generate(Dialect dialect) {
    cfg.setProperty("hibernate.dialect", dialect.getDialectClass());
    SchemaExport export = new SchemaExport(cfg);
    export.setDelimiter(";");
  
    export.setOutputFile("_ddl_" + dialect.name().toLowerCase() + ".sql");
    export.setFormat(true);
    export.execute(true, false, false, false);
}
 
開發者ID:jbosschina,項目名稱:wildfly-dev-cookbook,代碼行數:10,代碼來源:SchemaGenerator.java


注:本文中的org.hibernate.tool.hbm2ddl.SchemaExport.setOutputFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。