net.sf.jsqlparser.statement.select.SelectBody Java Examples

The following examples show how to use net.sf.jsqlparser.statement.select.SelectBody. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SqlTest.java    From Mybatis-PageHelper with MIT License 6 votes vote down vote up
@Test
public void testWithNolock(){
    String sql = "SELECT * FROM A WITH(NOLOCK) INNER JOIN B WITH(NOLOCK) ON A.TypeId = B.Id";
    System.out.println(sql);
    sql = sql.replaceAll("((?i)\\s*(\\w?)\\s*with\\s*\\(nolock\\))", " $2_PAGEWITHNOLOCK");
    System.out.println(sql);
    //解析SQL
    Statement stmt = null;
    try {
        stmt = CCJSqlParserUtil.parse(sql);
    } catch (Throwable e) {
        e.printStackTrace();
        return;
    }
    Select select = (Select) stmt;
    SelectBody selectBody = select.getSelectBody();
    sql = selectBody.toString();

    sql = sql.replaceAll("\\s*(\\w*?)_PAGEWITHNOLOCK", " $1 WITH(NOLOCK)");

    System.out.println(sql);
}
 
Example #2
Source File: SelectVisitorImpl.java    From DataPermissionHelper with Apache License 2.0 4 votes vote down vote up
@Override
public void visit(SetOperationList setOpList) {
    for (SelectBody plainSelect : setOpList.getSelects()) {
        plainSelect.accept(new SelectVisitorImpl());
    }
}
 
Example #3
Source File: CTEToNestedQueryConverter.java    From quetzal with Eclipse Public License 2.0 4 votes vote down vote up
public ReplacementFromItemVisitor(Map<String, SelectBody> cteName2Def,Set<String> placeHolderTables ) {
	super();
	this.cteName2Def = cteName2Def;
	this.placeHolderTables = placeHolderTables;
}
 
Example #4
Source File: CTEToNestedQueryConverter.java    From quetzal with Eclipse Public License 2.0 4 votes vote down vote up
public ReplacementSelectVisitor(Map<String, SelectBody> cteName2Def, Set<String> placeHolderTables) {
	super();
	this.cteName2Def = cteName2Def;
	this.placeHolderTables= placeHolderTables;
}
 
Example #5
Source File: CTEToNestedQueryConverter.java    From quetzal with Eclipse Public License 2.0 4 votes vote down vote up
public void replace(SelectBody r, Map<String, SelectBody> cteName2Def,Set<String> placeHolderTables) {
	r.accept(new ReplacementSelectVisitor(cteName2Def, placeHolderTables));
}