1 package liquibase.sqlgenerator.core; 2 3 import liquibase.database.Database; 4 import liquibase.database.core.H2Database; 5 import liquibase.database.core.HsqlDatabase; 6 import liquibase.exception.DatabaseException; 7 import liquibase.exception.UnexpectedLiquibaseException; 8 import liquibase.sql.Sql; 9 import liquibase.sql.UnparsedSql; 10 import liquibase.sqlgenerator.SqlGeneratorChain; 11 import liquibase.statement.core.GetViewDefinitionStatement; 12 13 public class GetViewDefinitionGeneratorHsql extends GetViewDefinitionGenerator { 14 @Override 15 public int getPriority() { 16 return PRIORITY_DATABASE; 17 } 18 19 @Override 20 public boolean supports(GetViewDefinitionStatement statement, Database database) { 21 return database instanceof HsqlDatabase; 22 } 23 24 @Override 25 public Sql[] generateSql(GetViewDefinitionStatement statement, Database database, 26 SqlGeneratorChain sqlGeneratorChain) { 27 try { 28 return new Sql[] { new UnparsedSql( 29 "SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.SYSTEM_VIEWS WHERE TABLE_NAME = '" 30 + statement.getViewName() + "' AND TABLE_SCHEMA='" 31 + database.convertRequestedSchemaToSchema(statement.getSchemaName()) + "'") }; 32 } catch (DatabaseException e) { 33 throw new UnexpectedLiquibaseException(e); 34 } 35 } 36 }