当前位置: 首页>>代码示例>>Java>>正文


Java TargetType类代码示例

本文整理汇总了Java中org.hibernate.tool.schema.TargetType的典型用法代码示例。如果您正苦于以下问题:Java TargetType类的具体用法?Java TargetType怎么用?Java TargetType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TargetType类属于org.hibernate.tool.schema包,在下文中一共展示了TargetType类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyConstraints

import org.hibernate.tool.schema.TargetType; //导入依赖的package包/类
protected void applyConstraints(Metadata metadata) {
	File tempFile = null;
   	try {
       	tempFile = File.createTempFile("schema", ".sql");
       	new SchemaExport().setOutputFile(tempFile.getAbsolutePath())
       			.setFormat(false).createOnly(EnumSet.of(TargetType.SCRIPT), metadata);
       	List<String> sqls = new ArrayList<>();
       	for (String sql: FileUtils.readLines(tempFile)) {
       		if (isApplyingConstraints(sql)) {
       			sqls.add(sql);
       		}
       	}
       	execute(sqls, true);
   	} catch (IOException e) {
   		throw new RuntimeException(e);
   	} finally {
   		if (tempFile != null)
   			tempFile.delete();
   	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:21,代码来源:DefaultPersistManager.java

示例2: createTables

import org.hibernate.tool.schema.TargetType; //导入依赖的package包/类
protected void createTables(Metadata metadata) {
	File tempFile = null;
   	try {
       	tempFile = File.createTempFile("schema", ".sql");
       	new SchemaExport().setOutputFile(tempFile.getAbsolutePath())
       			.setFormat(false).createOnly(EnumSet.of(TargetType.SCRIPT), metadata);
       	List<String> sqls = new ArrayList<>();
       	for (String sql: FileUtils.readLines(tempFile)) {
       		if (shouldInclude(sql) && !isApplyingConstraints(sql))
       			sqls.add(sql);
       	}
       	execute(sqls, true);
   	} catch (IOException e) {
   		throw new RuntimeException(e);
   	} finally {
   		if (tempFile != null)
   			FileUtils.deleteFile(tempFile);
   	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:20,代码来源:DefaultPersistManager.java

示例3: dropConstraints

import org.hibernate.tool.schema.TargetType; //导入依赖的package包/类
protected void dropConstraints(Metadata metadata) {
	File tempFile = null;
   	try {
       	tempFile = File.createTempFile("schema", ".sql");
       	new SchemaExport().setOutputFile(tempFile.getAbsolutePath())
       			.setFormat(false).drop(EnumSet.of(TargetType.SCRIPT), metadata);
       	List<String> sqls = new ArrayList<>();
       	for (String sql: FileUtils.readLines(tempFile)) {
       		if (isDroppingConstraints(sql))
       			sqls.add(sql);
       	}
       	execute(sqls, false);
   	} catch (IOException e) {
   		throw new RuntimeException(e);
   	} finally {
   		if (tempFile != null)
   			tempFile.delete();
   	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:20,代码来源:DefaultPersistManager.java

示例4: cleanDatabase

import org.hibernate.tool.schema.TargetType; //导入依赖的package包/类
protected void cleanDatabase(Metadata metadata) {
	File tempFile = null;
   	try {
       	tempFile = File.createTempFile("schema", ".sql");
       	new SchemaExport().setOutputFile(tempFile.getAbsolutePath())
       			.setFormat(false).drop(EnumSet.of(TargetType.SCRIPT), metadata);
       	List<String> sqls = new ArrayList<>();
       	for (String sql: FileUtils.readLines(tempFile)) {
       		sqls.add(sql);
       	}
       	execute(sqls, false);
   	} catch (IOException e) {
   		throw new RuntimeException(e);
   	} finally {
   		if (tempFile != null)
   			tempFile.delete();
   	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:19,代码来源:DefaultPersistManager.java

示例5: outputDdl

import org.hibernate.tool.schema.TargetType; //导入依赖的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

示例6: generate

import org.hibernate.tool.schema.TargetType; //导入依赖的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

示例7: main

import org.hibernate.tool.schema.TargetType; //导入依赖的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

示例8: createSQLSchema

import org.hibernate.tool.schema.TargetType; //导入依赖的package包/类
private void createSQLSchema(String fileName, String dialect) {
        File file = new File(fileName);
        if (file.exists()) {
            file.delete();
        }

        MetadataSources metadata = new MetadataSources(
                new StandardServiceRegistryBuilder()
                        .applySetting("hibernate.implicit_naming_strategy", new MidPointImplicitNamingStrategy())
                        .applySetting("hibernate.physical_naming_strategy", new MidPointPhysicalNamingStrategy())
                        .applySetting("hibernate.dialect", dialect)
                        .build());

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

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

        SchemaExport export = new SchemaExport();
        export.setOutputFile(fileName);
        export.setDelimiter(";");
//        export.setFormat(true);
        export.execute(EnumSet.of(TargetType.SCRIPT), SchemaExport.Action.CREATE, metadata.buildMetadata());
    }
 
开发者ID:Evolveum,项目名称:midpoint,代码行数:32,代码来源:SchemaTest.java

示例9: dropAndCreate

import org.hibernate.tool.schema.TargetType; //导入依赖的package包/类
public void dropAndCreate() {

	  //    SchemaExport export = new SchemaExport(HibernateUtil.getConfiguration());
//	    export.drop(true, true);
	    //    export.create(true, true);
		
		
		MetadataSources metadata = new MetadataSources(
			    new StandardServiceRegistryBuilder()
			        .applySetting("hibernate.dialect", "org.hibernate.dialect.H2Dialect")
			        .applySetting("javax.persistence.schema-generation-connection", this.getConnection())
			        .build());

		
    SchemaExport export = new SchemaExport();
    export.create(EnumSet.of(TargetType.DATABASE), metadata.buildMetadata());

  }
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:19,代码来源:GeodatabaseHibernate.java

示例10: writeSqlDiffScript

import org.hibernate.tool.schema.TargetType; //导入依赖的package包/类
public static void writeSqlDiffScript(ConfigurableApplicationContext context, String fileName, String action) {
	EntityManagerFactory entityManagerFactory = context.getBean(EntityManagerFactory.class);
	EntityManager entityManager = entityManagerFactory.createEntityManager();
	
	ExecutionOptions executionOptions = new ExecutionOptions() {
		
		@Override
		public boolean shouldManageNamespaces() {
			return false;
		}
		
		@Override
		public Map<?, ?> getConfigurationValues() {
			return Maps.newHashMap();
		}
		
		@Override
		public ExceptionHandler getExceptionHandler() {
			// TODO récupérer et vérifier aucune exception pendant la mise à jour
			return new ExceptionHandlerCollectingImpl();
		}
	};
	
	ServiceRegistry serviceRegistry = ((SessionImpl) entityManager.getDelegate()).getSessionFactory().getServiceRegistry();
	Metadata metadata = MetadataRegistryIntegrator.METADATA;
	
	EnumSet<TargetType> targetTypes = EnumSet.of(TargetType.SCRIPT);
	TargetDescriptor targetDescriptor = SchemaExport.buildTargetDescriptor(targetTypes, fileName, serviceRegistry);
	
	if (action.equals("create")) {
		final SourceDescriptor sourceDescriptor = new SourceDescriptor() {
			@Override
			public SourceType getSourceType() {
				return SourceType.METADATA;
			}
			
			@Override
			public ScriptSourceInput getScriptSourceInput() {
				return null;
			}
		};
		serviceRegistry.getService(SchemaManagementTool.class).getSchemaCreator(Maps.newHashMap())
				.doCreation(metadata, executionOptions, sourceDescriptor, targetDescriptor);
	} else if (action.equals("update")) {
		serviceRegistry.getService(SchemaManagementTool.class).getSchemaMigrator(Maps.newHashMap())
				.doMigration(metadata, executionOptions, targetDescriptor);
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:49,代码来源:SqlUpdateScript.java

示例11: createDatabase

import org.hibernate.tool.schema.TargetType; //导入依赖的package包/类
public void createDatabase() throws HibernateException {
    // executes a drop and a create!
    new SchemaExport().create(EnumSet.of(TargetType.DATABASE), metadata);
}
 
开发者ID:testIT-LivingDoc,项目名称:livingdoc-confluence,代码行数:5,代码来源:HibernateDatabase.java


注:本文中的org.hibernate.tool.schema.TargetType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。