當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。