如何解析Mybatis xml文件中配置的sql
展开全部
首先抽象一个SQL语句类:
[java] view plain copy
public abstract class AbstractSQLStatementNode implements ISQLStatement {
protected List<ISQLStatement> sqlStatements = new ArrayList<>();
@Override
public void appendSQL(ISQLStatement sql) {
sqlStatements.add(sql);
}
然后是文本SQL:
[java] view plain copy
public class PlainSQLNode extends AbstractSQLStatementNode {
private final String sql;
public PlainSQLNode(String sql) {
this.sql = sql;
}
[java] view plain copy
public abstract class AbstractSQLStatementNode implements ISQLStatement {
protected List<ISQLStatement> sqlStatements = new ArrayList<>();
@Override
public void appendSQL(ISQLStatement sql) {
sqlStatements.add(sql);
}
然后是文本SQL:
[java] view plain copy
public class PlainSQLNode extends AbstractSQLStatementNode {
private final String sql;
public PlainSQLNode(String sql) {
this.sql = sql;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询