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


Java CreateViewGenerator类代码示例

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


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

示例1: generateSql

import liquibase.sqlgenerator.core.CreateViewGenerator; //导入依赖的package包/类
/**
 * 1. View creation to be set to run once only, no more runAlways="true".
 * 2. If there is a materialized view with the same name as this view, we drop it.
 * 3. We can then can create the standard view: 'create or replace force view as ... select 1 from dual' 
 * 4. If the environment is set for materialized views, convert all views to materialized views at the end using the v99.99.99 script.
 */
public Sql[] generateSql( CreateFlexibleViewStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain ) {
	// check if the view already exists, then formulate a plan from there!
	String viewName = statement.getViewName().toUpperCase();
	List<Sql> sequel = new ArrayList<Sql>();

	OracleMaterializedViewExistsPrecondition matViewExistsCondition = new OracleMaterializedViewExistsPrecondition();
	matViewExistsCondition.setViewName( viewName );
	if ( matViewExistsCondition.check( database ) ) {
		DropMaterializedViewStatement dropMViewStmt = new DropMaterializedViewStatement( statement.getViewName() );
		dropMViewStmt.setSchemaName( database.getLiquibaseSchemaName() );
		DropMaterializedViewOracle dropMViewGen = new DropMaterializedViewOracle();
		sequel.addAll( Arrays.asList( dropMViewGen.generateSql( dropMViewStmt, database, null ) ) );
	}
	
	// if the view exists as a regular view already, we don't actually care.
	CreateViewStatement createViewStmt = new CreateViewStatement( database.getLiquibaseCatalogName(), database.getLiquibaseSchemaName(), statement.getViewName(), statement.getSelectQuery(), true );

	CreateViewGenerator createViewGen = new CreateViewGenerator();
	sequel.addAll( Arrays.asList( createViewGen.generateSql( createViewStmt, database, null ) ) );

	return sequel.toArray( new Sql[0] );
}
 
开发者ID:mrswadge,项目名称:liquibase-flexibleview,代码行数:29,代码来源:CreateFlexibleViewGenerator.java


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