net.sf.jsqlparser.expression.operators.relational.GreaterThan Java Examples

The following examples show how to use net.sf.jsqlparser.expression.operators.relational.GreaterThan. 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: GreaterThanExpressionConverter.java    From sqlhelper with GNU Lesser General Public License v3.0 5 votes vote down vote up
public GreaterThanExpressionConverter(){
    setJsqlparserExpressionSupplier(new Supplier<GreaterThanExpression, GreaterThan>() {
        @Override
        public GreaterThan get(GreaterThanExpression input) {
            return new GreaterThan();
        }
    });
}
 
Example #2
Source File: GreaterThanExpressionConverter.java    From sqlhelper with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Class<GreaterThan> getJSqlParserExpressionClass() {
    return GreaterThan.class;
}
 
Example #3
Source File: ExpressionVisitorImpl.java    From DataPermissionHelper with Apache License 2.0 4 votes vote down vote up
@Override
public void visit(GreaterThan greaterThan) {
    visitBinaryExpression(greaterThan);
}
 
Example #4
Source File: DMLWhereClauseVisitorAdapter.java    From spanner-jdbc with MIT License 4 votes vote down vote up
@Override
public void visit(GreaterThan expr) {
  invalid = true;
  super.visit(expr);
}
 
Example #5
Source File: SqlServer.java    From genericdao with Artistic License 2.0 4 votes vote down vote up
/**
 * 获取一个外层包装的TOP查询
 *
 * @param select
 * @return
 */
private Select getPageSelect(Select select, String orderBy) {
    SelectBody selectBody = select.getSelectBody();
    if (selectBody instanceof SetOperationList) {
        selectBody = wrapSetOperationList((SetOperationList) selectBody);
    }
    //这里的selectBody一定是PlainSelect
    if (((PlainSelect) selectBody).getTop() != null) {
        throw new RuntimeException("被分页的语句已经包含了Top,不能再通过分页插件进行分页查询!");
    }
    //获取查询列
    List<SelectItem> selectItems = getSelectItems((PlainSelect) selectBody);
    //对一层的SQL增加ROW_NUMBER()
    addRowNumber((PlainSelect) selectBody, orderBy);
    //处理子语句中的order by
    processSelectBody(selectBody, 0);

    //新建一个select
    Select newSelect = new Select();
    PlainSelect newSelectBody = new PlainSelect();
    //设置top
    Top top = new Top();
    top.setRowCount(Long.MAX_VALUE);
    newSelectBody.setTop(top);
    //设置order by
    List<OrderByElement> orderByElements = new ArrayList<OrderByElement>();
    OrderByElement orderByElement = new OrderByElement();
    orderByElement.setExpression(PAGE_ROW_NUMBER_COLUMN);
    orderByElements.add(orderByElement);
    newSelectBody.setOrderByElements(orderByElements);
    //设置where
    GreaterThan greaterThan = new GreaterThan();
    greaterThan.setLeftExpression(PAGE_ROW_NUMBER_COLUMN);
    greaterThan.setRightExpression(new LongValue(Long.MIN_VALUE));
    newSelectBody.setWhere(greaterThan);
    //设置selectItems
    newSelectBody.setSelectItems(selectItems);
    //设置fromIterm
    SubSelect fromItem = new SubSelect();
    fromItem.setSelectBody(selectBody);
    fromItem.setAlias(PAGE_TABLE_ALIAS);
    newSelectBody.setFromItem(fromItem);

    newSelect.setSelectBody(newSelectBody);
    if (isNotEmptyList(select.getWithItemsList())) {
        newSelect.setWithItemsList(select.getWithItemsList());
    }
    return newSelect;
}
 
Example #6
Source File: SqlServerParser.java    From Mybatis-PageHelper with MIT License 4 votes vote down vote up
/**
 * 获取一个外层包装的TOP查询
 *
 * @param select
 * @return
 */
protected Select getPageSelect(Select select) {
    SelectBody selectBody = select.getSelectBody();
    if (selectBody instanceof SetOperationList) {
        selectBody = wrapSetOperationList((SetOperationList) selectBody);
    }
    //这里的selectBody一定是PlainSelect
    if (((PlainSelect) selectBody).getTop() != null) {
        throw new PageException("被分页的语句已经包含了Top,不能再通过分页插件进行分页查询!");
    }
    //获取查询列
    List<SelectItem> selectItems = getSelectItems((PlainSelect) selectBody);
    //对一层的SQL增加ROW_NUMBER()
    List<SelectItem> autoItems = new ArrayList<SelectItem>();
    SelectItem orderByColumn = addRowNumber((PlainSelect) selectBody, autoItems);
    //加入自动生成列
    ((PlainSelect) selectBody).addSelectItems(autoItems.toArray(new SelectItem[autoItems.size()]));
    //处理子语句中的order by
    processSelectBody(selectBody, 0);

    //中层子查询
    PlainSelect innerSelectBody = new PlainSelect();
    //PAGE_ROW_NUMBER
    innerSelectBody.addSelectItems(orderByColumn);
    innerSelectBody.addSelectItems(selectItems.toArray(new SelectItem[selectItems.size()]));
    //将原始查询作为内层子查询
    SubSelect fromInnerItem = new SubSelect();
    fromInnerItem.setSelectBody(selectBody);
    fromInnerItem.setAlias(PAGE_TABLE_ALIAS);
    innerSelectBody.setFromItem(fromInnerItem);

    //新建一个select
    Select newSelect = new Select();
    PlainSelect newSelectBody = new PlainSelect();
    //设置top
    Top top = new Top();
    top.setExpression(new LongValue(Long.MAX_VALUE));
    newSelectBody.setTop(top);
    //设置order by
    List<OrderByElement> orderByElements = new ArrayList<OrderByElement>();
    OrderByElement orderByElement = new OrderByElement();
    orderByElement.setExpression(PAGE_ROW_NUMBER_COLUMN);
    orderByElements.add(orderByElement);
    newSelectBody.setOrderByElements(orderByElements);
    //设置where
    GreaterThan greaterThan = new GreaterThan();
    greaterThan.setLeftExpression(PAGE_ROW_NUMBER_COLUMN);
    greaterThan.setRightExpression(new LongValue(Long.MIN_VALUE));
    newSelectBody.setWhere(greaterThan);
    //设置selectItems
    newSelectBody.setSelectItems(selectItems);
    //设置fromIterm
    SubSelect fromItem = new SubSelect();
    fromItem.setSelectBody(innerSelectBody); //中层子查询
    fromItem.setAlias(PAGE_TABLE_ALIAS);
    newSelectBody.setFromItem(fromItem);

    newSelect.setSelectBody(newSelectBody);
    if (isNotEmptyList(select.getWithItemsList())) {
        newSelect.setWithItemsList(select.getWithItemsList());
    }
    return newSelect;
}
 
Example #7
Source File: CTEToNestedQueryConverter.java    From quetzal with Eclipse Public License 2.0 2 votes vote down vote up
@Override
public void visit(GreaterThan greaterThan) {
	visitBinary(greaterThan, false);
	
	
}