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

The following examples show how to use net.sf.jsqlparser.statement.select.SelectBody. These examples are extracted from open source projects. 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 Project: Mybatis-PageHelper   Source File: SqlTest.java    License: 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 Project: DataPermissionHelper   Source File: SelectVisitorImpl.java    License: 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 Project: quetzal   Source File: CTEToNestedQueryConverter.java    License: 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 Project: quetzal   Source File: CTEToNestedQueryConverter.java    License: 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 Project: quetzal   Source File: CTEToNestedQueryConverter.java    License: 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));
}