当前位置: 首页>>代码示例>>Java>>正文


Java SQLSelectOrderByItem类代码示例

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


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


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