We offer an option to remove block comments and line comments from SQL templates.
Which comments to delete will be indicated in the implementation class of SqlParserConfig:
public class LineCommentRemovalSqlParserConfig implements SqlParserConfig {
@Override
public boolean shouldRemoveBlockComment(String comment) {
return false;
}
@Override
public boolean shouldRemoveLineComment(String comment) {
return true;
}
}
Pass an instance of the above class to the constructor of the implementation class of SqlFileRepository:
public class AppConfig implements Config {
...
private final SqlFileRepository sqlFileRepository =
new GreedyCacheSqlFileRepository(new LineCommentRemovalSqlParserConfig());
@Override
public SqlFileRepository getSqlFileRepository() {
return sqlFileRepository;
}
}
Let's apply the above configuration to the following SQL template:
/**
* This comment will not be removed
*/
select
*
from
EMPLOYEE -- this comment will be removed
where
EMPLOYEE_ID = /*employeeId*/0 -- this comment will be also removed
The result of the application is as follows:
/**
* This comment will not be removed
*/
select
*
from
EMPLOYEE
where
EMPLOYEE_ID = ?
We offer an option to remove block comments and line comments from SQL templates.
Which comments to delete will be indicated in the implementation class of
SqlParserConfig
:Pass an instance of the above class to the constructor of the implementation class of
SqlFileRepository
:Let's apply the above configuration to the following SQL template:
The result of the application is as follows: