• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SQLSelectOrderByItem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem的典型用法代码示例。如果您正苦于以下问题:Java SQLSelectOrderByItem类的具体用法?Java SQLSelectOrderByItem怎么用?Java SQLSelectOrderByItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SQLSelectOrderByItem类属于com.alibaba.druid.sql.ast.statement包,在下文中一共展示了SQLSelectOrderByItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: parseOrderAggGroupMysql

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
protected void parseOrderAggGroupMysql(SchemaConfig schema, SQLStatement stmt, RouteResultset rrs, MySqlSelectQueryBlock mysqlSelectQuery)
	{
		MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor();
		stmt.accept(visitor);
//		rrs.setGroupByCols((String[])visitor.getGroupByColumns().toArray());
		if(!isNeedParseOrderAgg)
        {
            return;
        }
		Map<String, String> aliaColumns = parseAggGroupCommon(schema, stmt, rrs, mysqlSelectQuery);

		//setOrderByCols
		if(mysqlSelectQuery.getOrderBy() != null) {
			List<SQLSelectOrderByItem> orderByItems = mysqlSelectQuery.getOrderBy().getItems();
			rrs.setOrderByCols(buildOrderByCols(orderByItems,aliaColumns));
		}
        isNeedParseOrderAgg=false;
	}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:19,代码来源:DruidSelectParser.java


示例2: buildOrderByCols

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
protected LinkedHashMap<String, Integer> buildOrderByCols(List<SQLSelectOrderByItem> orderByItems,Map<String, String> aliaColumns) {
	LinkedHashMap<String, Integer> map = new LinkedHashMap<String, Integer>();
	for(int i= 0; i < orderByItems.size(); i++) {
		SQLOrderingSpecification type = orderByItems.get(i).getType();
           //orderColumn只记录字段名称,因为返回的结果集是不带表名的。
		SQLExpr expr =  orderByItems.get(i).getExpr();
		String col;
		if (expr instanceof SQLName) {
		   col = ((SQLName)expr).getSimpleName();
		}
		else {
			col =expr.toString();
		}
		if(type == null) {
			type = SQLOrderingSpecification.ASC;
		}
		col=getAliaColumn(aliaColumns,col);//此步骤得到的col必须是不带.的,有别名的用别名,无别名的用字段名
		map.put(col, type == SQLOrderingSpecification.ASC ? OrderCol.COL_ORDER_TYPE_ASC : OrderCol.COL_ORDER_TYPE_DESC);
	}
	return map;
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:22,代码来源:DruidSelectParser.java


示例3: clone

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
public SearchClause clone() {
    SearchClause x = new SearchClause();

    x.type = type;

    for (SQLSelectOrderByItem item : items) {
        SQLSelectOrderByItem item2 = item.clone();
        item2.setParent(x);
        x.items.add(item2);
    }

    if (orderingColumn != null) {
        x.setOrderingColumn(orderingColumn.clone());
    }

    return x;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:18,代码来源:SearchClause.java


示例4: toExpression

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
@Override
public SQLExpr toExpression() {
    SQLAggregateExpr aggregate = new SQLAggregateExpr(funcName());
    if (hasWithDistinct()) {
        aggregate.setOption(SQLAggregateOption.DISTINCT);
    }
    if (orders != null) {
        SQLOrderBy orderBy = new SQLOrderBy();
        for (Order order : orders) {
            SQLSelectOrderByItem orderItem = new SQLSelectOrderByItem(order.getItem().toExpression());
            orderItem.setType(order.getSortOrder());
            orderBy.addItem(orderItem);
        }
        aggregate.putAttribute(ItemFuncKeyWord.ORDER_BY, orderBy);
    }
    for (Item arg : args) {
        aggregate.addArgument(arg.toExpression());
    }
    if (seperator != null) {
        SQLCharExpr sep = new SQLCharExpr(seperator);
        aggregate.putAttribute(ItemFuncKeyWord.SEPARATOR, sep);
    }
    return aggregate;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:25,代码来源:ItemFuncGroupConcat.java


示例5: parseOneIdx

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
private Map parseOneIdx(String idx)
{
  Map map = new HashMap();
  OracleStatementParser parser = new OracleStatementParser(idx);
  OracleCreateIndexStatement statement = parser.parseCreateIndex(true);
  SQLExprTableSource tableSource = (SQLExprTableSource) statement.getTable();
  String tableName = ((SQLPropertyExpr) tableSource.getExpr()).getSimleName().toLowerCase();
  String idxType = statement.getType();
  List<SQLSelectOrderByItem> items = statement.getItems();
  List fields = new ArrayList();
  for (SQLSelectOrderByItem item : items)
  {
    SQLIdentifierExpr expr = (SQLIdentifierExpr) item.getExpr();
    fields.add(expr.getSimleName().toLowerCase());
  }
  if ("unique".equalsIgnoreCase(idxType))
    map.put(tableName, fields);
  return map;
}
 
开发者ID:iisi-nj,项目名称:GemFireLite,代码行数:20,代码来源:OracleDdlParser.java


示例6: reverseAppendTo

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
private void reverseAppendTo(SQLSelectOrderByItem order, SQLServerOutputVisitor visitor, String tmpTableAlias, List<SQLSelectItem> items) {
	SQLExpr expression=order.getExpr();
	
	if(expression instanceof SQLPropertyExpr){
		SQLPropertyExpr c=(SQLPropertyExpr)expression;
		if(items!=null){
			fixWithSelects(c,items);
		}
		if(c.getOwner()!=null){
			c.setOwner(new SQLIdentifierExpr(tmpTableAlias));
		}
	}
	expression.accept(visitor);
	if(order.getType()==SQLOrderingSpecification.ASC || order.getType()==null){
		try {
			visitor.getAppender().append(" DESC");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:GeeQuery,项目名称:ef-orm,代码行数:22,代码来源:SQL2000LimitHandler.java


示例7: parserOrderBy

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
private void parserOrderBy(SQLOrderBy orderby)   
  {   
if (orderby != null ){
	for (int i = 0; i < orderby.getItems().size(); i++)
       {
	  SQLSelectOrderByItem orderitem = orderby.getItems().get(i);
	  tableFilter.addOrders(orderitem.getExpr().toString(), getSQLExprToAsc(orderitem.getType()));
          }
}		
  }
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:11,代码来源:JoinParser.java


示例8: parseOrderAggGroupOracle

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
protected void parseOrderAggGroupOracle(SQLStatement stmt, RouteResultset rrs, OracleSelectQueryBlock mysqlSelectQuery, SchemaConfig schema)
{
	Map<String, String> aliaColumns = parseAggGroupCommon(schema, stmt,rrs, mysqlSelectQuery);

	OracleSelect oracleSelect= (OracleSelect) mysqlSelectQuery.getParent();
	if(oracleSelect.getOrderBy() != null) {
		List<SQLSelectOrderByItem> orderByItems = oracleSelect.getOrderBy().getItems();
		rrs.setOrderByCols(buildOrderByCols(orderByItems,aliaColumns));
	}
       isNeedParseOrderAgg=false;
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:12,代码来源:DruidSelectOracleParser.java


示例9: parseOrderAggGroupSqlServer

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
private void parseOrderAggGroupSqlServer(SchemaConfig schema, SQLStatement stmt, RouteResultset rrs, SQLServerSelectQueryBlock mysqlSelectQuery)
{
	Map<String, String> aliaColumns = parseAggGroupCommon(schema, stmt,rrs, mysqlSelectQuery);

	SQLServerSelect oracleSelect= (SQLServerSelect) mysqlSelectQuery.getParent();
	if(oracleSelect.getOrderBy() != null) {
		List<SQLSelectOrderByItem> orderByItems = oracleSelect.getOrderBy().getItems();
		rrs.setOrderByCols(buildOrderByCols(orderByItems,aliaColumns));
	}
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:11,代码来源:DruidSelectSqlServerParser.java


示例10: clone

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
public SQLOrderBy clone() {
    SQLOrderBy x = new SQLOrderBy();

    for (SQLSelectOrderByItem item : items) {
        SQLSelectOrderByItem item1 = item.clone();
        item1.setParent(x);
        x.items.add(item1);
    }

    x.sibings = sibings;

    return x;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:14,代码来源:SQLOrderBy.java


示例11: clone

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
public MySqlTableIndex clone() {
    MySqlTableIndex x = new MySqlTableIndex();
    if (name != null) {
        x.setName(name.clone());
    }
    x.indexType = indexType;
    for (SQLSelectOrderByItem column : columns) {
        SQLSelectOrderByItem c2 = column.clone();
        c2.setParent(x);
        x.columns.add(c2);
    }
    return x;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:14,代码来源:MySqlTableIndex.java


示例12: applyColumnRename

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
public boolean applyColumnRename(SQLName columnName, SQLName to) {
    for (SQLSelectOrderByItem orderByItem : columns) {
        SQLExpr expr = orderByItem.getExpr();
        if (expr instanceof SQLName
                && SQLUtils.nameEquals((SQLName) expr, columnName)) {
            orderByItem.setExpr(to.clone());
            return true;
        }
    }
    return false;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:12,代码来源:MySqlTableIndex.java


示例13: parseOrderby

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
/**
 * 解析Orderby
 * @param result
 * @param plan
 * @param mysqlSelectQuery
 */
protected void parseOrderby(ParseResult result, ExecutePlan plan, MySqlSelectQueryBlock mysqlSelectQuery){
    if (mysqlSelectQuery.getOrderBy() == null){
        return;
    }
    List<SQLSelectOrderByItem> orderByItems = mysqlSelectQuery.getOrderBy().getItems();
    if (orderByItems == null || orderByItems.size() == 0){
        return;
    }
    List<SQLSelectItem> selectList      = mysqlSelectQuery.getSelectList();
    List<OrderbyColumn> orderbyColumns  = new ArrayList<OrderbyColumn>(orderByItems.size());
    for(SQLSelectOrderByItem item : orderByItems){
        String name = StringUtil.removeDot(item.getExpr().toString());
        if (result.getAliaColumns() != null){
            String alias = result.getAliaColumns().get(name);
            if (alias != null){
                // select user_id as uid ....order by user_id
                // 要把oderby的user_id转换为uid,以便结果集合并
                orderbyColumns.add(new OrderbyColumn(alias, OrderbyColumn.buildOrderbyType(item.getType())));
                continue;
            }
        }
        if (!result.isHasAllColumnExpr()){
            // select列表中没有orderby的字段 添加,用于后面做合并
            SQLIdentifierExpr exp = new SQLIdentifierExpr(name);

            // item
            SQLSelectItem addItem = new SQLSelectItem();
            addItem.setExpr(exp);
            exp.setParent(item);
            selectList.add(addItem);
        }
        orderbyColumns.add(new OrderbyColumn(name, OrderbyColumn.buildOrderbyType(item.getType())));
    }
    plan.setOrderbyColumns(orderbyColumns);
}
 
开发者ID:tongbanjie,项目名称:baymax,代码行数:42,代码来源:MySqlSelectParser.java


示例14: appendOrderReverse

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
private void appendOrderReverse(SQLOrderBy order, SQLServerOutputVisitor visitor,String tmpTableAlias,List<SQLSelectItem> items) {
	StringBuilder sb=(StringBuilder)visitor.getAppender();
	sb.append( " ORDER BY ");
	Iterator<SQLSelectOrderByItem> iter=order.getItems().iterator();
	if(iter.hasNext()){
		reverseAppendTo(iter.next(),visitor,tmpTableAlias,items);
	}
	for(;iter.hasNext();){
		sb.append(',');
		reverseAppendTo(iter.next(),visitor,tmpTableAlias,items);
	}
	
}
 
开发者ID:GeeQuery,项目名称:ef-orm,代码行数:14,代码来源:SQL2000LimitHandler.java


示例15: SQL2005LimitHandler

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
public SQL2005LimitHandler() {
	super();
	defaultOrder = new SQLOrderBy();
	SQLSelectOrderByItem oe = new SQLSelectOrderByItem();
	oe.setExpr(new SQLIdentifierExpr("CURRENT_TIMESTAMP"));
	defaultOrder.getItems().add(oe);
}
 
开发者ID:GeeQuery,项目名称:ef-orm,代码行数:8,代码来源:SQL2005LimitHandler.java


示例16: SQLOrderBy

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
public SQLOrderBy(SQLExpr expr){
    SQLSelectOrderByItem item = new SQLSelectOrderByItem(expr);
    addItem(item);
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:5,代码来源:SQLOrderBy.java


示例17: addItem

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
public void addItem(SQLSelectOrderByItem item) {
    if (item != null) {
        item.setParent(this);
    }
    this.items.add(item);
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:7,代码来源:SQLOrderBy.java


示例18: getItems

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
public List<SQLSelectOrderByItem> getItems() {
    return this.items;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:4,代码来源:SQLOrderBy.java


示例19: createItem

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
protected SQLSelectOrderByItem createItem() {
    return new SQLSelectOrderByItem();
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:4,代码来源:SQLOrderBy.java


示例20: getItems

import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem; //导入依赖的package包/类
public List<SQLSelectOrderByItem> getItems() {
    return items;
}
 
开发者ID:zuonima,项目名称:sql-utils,代码行数:4,代码来源:SearchClause.java



注:本文中的com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StreamUtils类代码示例发布时间:2022-05-22
下一篇:
Java Macro类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap