net.sf.jsqlparser.statement.select.Select.setSelectBody()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.3k)|赞(0)|评价(0)|浏览(332)

本文整理了Java中net.sf.jsqlparser.statement.select.Select.setSelectBody()方法的一些代码示例,展示了Select.setSelectBody()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Select.setSelectBody()方法的具体详情如下:
包路径:net.sf.jsqlparser.statement.select.Select
类名称:Select
方法名:setSelectBody

Select.setSelectBody介绍

暂无

代码示例

代码示例来源:origin: JSQLParser/JSqlParser

public static Select buildSelectFromTableAndSelectItems(Table table, SelectItem... selectItems) {
  Select select = new Select();
  PlainSelect body = new PlainSelect();
  body.addSelectItems(selectItems);
  body.setFromItem(table);
  select.setSelectBody(body);
  return select;
}

代码示例来源:origin: JSQLParser/JSqlParser

final public Select Select() throws ParseException {Select select = new Select();
  SelectBody selectBody = null;
  List<WithItem> with = null;
  switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
  case K_WITH:{
   with = WithList();

   break;
   }
  default:
   jj_la1[93] = jj_gen;
   ;
  }
  selectBody = SelectBody();
select.setWithItemsList(with);
    select.setSelectBody(selectBody);
    return select;
}

代码示例来源:origin: alibaba/mdrill

final public Select Select() throws ParseException {
   Select select = new Select();
   SelectBody selectBody = null;
   List with = null;
 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
 case K_WITH:
  with = WithList();
             select.setWithItemsList(with);
  break;
 default:
  jj_la1[22] = jj_gen;
  ;
 }
 selectBody = SelectBody();
       select.setSelectBody(selectBody);
       {if (true) return select;}
 throw new Error("Missing return statement in function");
}

代码示例来源:origin: pagehelper/Mybatis-PageHelper

/**
 * 将sql转换为count查询
 *
 * @param select
 */
public void sqlToCount(Select select, String name) {
  SelectBody selectBody = select.getSelectBody();
  // 是否能简化count查询
  List<SelectItem> COUNT_ITEM = new ArrayList<SelectItem>();
  COUNT_ITEM.add(new SelectExpressionItem(new Column("count(" + name +")")));
  if (selectBody instanceof PlainSelect && isSimpleCount((PlainSelect) selectBody)) {
    ((PlainSelect) selectBody).setSelectItems(COUNT_ITEM);
  } else {
    PlainSelect plainSelect = new PlainSelect();
    SubSelect subSelect = new SubSelect();
    subSelect.setSelectBody(selectBody);
    subSelect.setAlias(TABLE_ALIAS);
    plainSelect.setFromItem(subSelect);
    plainSelect.setSelectItems(COUNT_ITEM);
    select.setSelectBody(plainSelect);
  }
}

代码示例来源:origin: pagehelper/Mybatis-PageHelper

newSelectBody.setFromItem(fromItem);
newSelect.setSelectBody(newSelectBody);
if (isNotEmptyList(select.getWithItemsList())) {
  newSelect.setWithItemsList(select.getWithItemsList());

代码示例来源:origin: com.github.jsqlparser/jsqlparser

public static Select buildSelectFromTableAndSelectItems(Table table, SelectItem... selectItems) {
  Select select = new Select();
  PlainSelect body = new PlainSelect();
  body.addSelectItems(selectItems);
  body.setFromItem(table);
  select.setSelectBody(body);
  return select;
}

代码示例来源:origin: com.eas.platypus/platypus-js-sql-parser

final public Select Select() throws ParseException {Select select = new Select();
    SelectBody selectBody = null;
    List with = null;
  switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
  case K_WITH:{
   with = WithList(select);
select.setWithItemsList(with);
   break;
   }
  default:
   jj_la1[24] = jj_gen;
   ;
  }
  selectBody = SelectBody();
select.setSelectBody(selectBody);
        {if ("" != null) return select;}
  throw new Error("Missing return statement in function");
 }

代码示例来源:origin: org.opencadc/cadc-jsqlparser-compat

final public Select Select() throws ParseException {Select select = new Select();
    SelectBody selectBody = null;
    List with = null;
  switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
  case K_WITH:{
   with = WithList();
select.setWithItemsList(with);
   break;
   }
  default:
   jj_la1[22] = jj_gen;
   ;
  }
  selectBody = SelectBody();
select.setSelectBody(selectBody);
        {if ("" != null) return select;}
  throw new Error("Missing return statement in function");
 }

代码示例来源:origin: com.github.jsqlparser/jsqlparser

final public Select Select() throws ParseException {Select select = new Select();
  SelectBody selectBody = null;
  List<WithItem> with = null;
  switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
  case K_WITH:{
   with = WithList();

   break;
   }
  default:
   jj_la1[93] = jj_gen;
   ;
  }
  selectBody = SelectBody();
select.setWithItemsList(with);
    select.setSelectBody(selectBody);
    return select;
}

代码示例来源:origin: it.unibz.inf.ontop/ontop-obdalib-core

/**
 * creates a query of the form SELECT * FROM viewName
 */

static ParsedSQLQuery createParsedSqlForGeneratedView(QuotedIDFactory idfac, RelationID viewId) {
  
  PlainSelect body = new PlainSelect();
  
  List<SelectItem> list = new ArrayList<>(1);
  list.add(new AllColumns());
  body.setSelectItems(list); // create SELECT *
  
  Table viewTable = new Table(viewId.getSchemaSQLRendering(), viewId.getTableNameSQLRendering());
  body.setFromItem(viewTable); // create FROM viewTable
  
  Select select = new Select();
  select.setSelectBody(body);
  
  ParsedSQLQuery queryParsed = null;
  try {
    queryParsed = new ParsedSQLQuery(select, false, idfac);
  } 
  catch (JSQLParserException e) {
    if (e.getCause() instanceof ParseException)
      log.warn("Parse exception, check no SQL reserved keywords have been used "+ e.getCause().getMessage());
  }
  return queryParsed;
}

代码示例来源:origin: fast-sql/FastSQL

/**
 * 将sql转换为count查询
 *
 */
public void sqlToCount(Select select, String name) {
  SelectBody selectBody = select.getSelectBody();
  // 是否能简化count查询
  List<SelectItem> COUNT_ITEM = new ArrayList<SelectItem>();
  COUNT_ITEM.add(new SelectExpressionItem(new Column("count(" + name + ")")));
  if (selectBody instanceof PlainSelect && isSimpleCount((PlainSelect) selectBody)) {
    ((PlainSelect) selectBody).setSelectItems(COUNT_ITEM);
  } else {
    PlainSelect plainSelect = new PlainSelect();
    SubSelect subSelect = new SubSelect();
    subSelect.setSelectBody(selectBody);
    subSelect.setAlias(TABLE_ALIAS);
    plainSelect.setFromItem(subSelect);
    plainSelect.setSelectItems(COUNT_ITEM);
    select.setSelectBody(plainSelect);
  }
}

代码示例来源:origin: com.github.pagehelper/pagehelper

/**
 * 将sql转换为count查询
 *
 * @param select
 */
public void sqlToCount(Select select, String name) {
  SelectBody selectBody = select.getSelectBody();
  // 是否能简化count查询
  List<SelectItem> COUNT_ITEM = new ArrayList<SelectItem>();
  COUNT_ITEM.add(new SelectExpressionItem(new Column("count(" + name +")")));
  if (selectBody instanceof PlainSelect && isSimpleCount((PlainSelect) selectBody)) {
    ((PlainSelect) selectBody).setSelectItems(COUNT_ITEM);
  } else {
    PlainSelect plainSelect = new PlainSelect();
    SubSelect subSelect = new SubSelect();
    subSelect.setSelectBody(selectBody);
    subSelect.setAlias(TABLE_ALIAS);
    plainSelect.setFromItem(subSelect);
    plainSelect.setSelectItems(COUNT_ITEM);
    select.setSelectBody(plainSelect);
  }
}

代码示例来源:origin: com.lodsve/lodsve-mybatis

/**
 * 将sql转换为count查询
 *
 * @param select select
 * @param name   name
 */
private static void sqlToCount(Select select, String name) {
  SelectBody selectBody = select.getSelectBody();
  // 是否能简化count查询
  List<SelectItem> countItem = new ArrayList<>();
  countItem.add(new SelectExpressionItem(new Column("COUNT(" + name + ")")));
  if (selectBody instanceof PlainSelect && isSimpleCount((PlainSelect) selectBody)) {
    ((PlainSelect) selectBody).setSelectItems(countItem);
  } else {
    PlainSelect plainSelect = new PlainSelect();
    SubSelect subSelect = new SubSelect();
    subSelect.setSelectBody(selectBody);
    subSelect.setAlias(TABLE_ALIAS);
    plainSelect.setFromItem(subSelect);
    plainSelect.setSelectItems(countItem);
    select.setSelectBody(plainSelect);
  }
}

代码示例来源:origin: com.hand.hap.cloud/hap-mybatis-mapper-starter

/**
 * 将sql转换为count查询
 *
 * @param select
 */
public void sqlToCount(Select select) {
  SelectBody selectBody = select.getSelectBody();
  // 是否能简化count查询
  if (selectBody instanceof PlainSelect && isSimpleCount((PlainSelect) selectBody)) {
    ((PlainSelect) selectBody).setSelectItems(COUNT_ITEM);
  } else {
    PlainSelect plainSelect = new PlainSelect();
    SubSelect subSelect = new SubSelect();
    subSelect.setSelectBody(selectBody);
    subSelect.setAlias(TABLE_ALIAS);
    plainSelect.setFromItem(subSelect);
    plainSelect.setSelectItems(COUNT_ITEM);
    select.setSelectBody(plainSelect);
  }
}

代码示例来源:origin: com.gitee.zhaohuihua/bdp-general-svc

/**
 * 将sql转换为count查询
 *
 * @param select
 */
public void sqlToCount(Select select) {
  SelectBody selectBody = select.getSelectBody();
  // 是否能简化count查询
  if (selectBody instanceof PlainSelect && isSimpleCount((PlainSelect) selectBody)) {
    ((PlainSelect) selectBody).setSelectItems(COUNT_ITEM);
  } else {
    PlainSelect plainSelect = new PlainSelect();
    SubSelect subSelect = new SubSelect();
    subSelect.setSelectBody(selectBody);
    subSelect.setAlias(TABLE_ALIAS);
    plainSelect.setFromItem(subSelect);
    plainSelect.setSelectItems(COUNT_ITEM);
    select.setSelectBody(plainSelect);
  }
}

代码示例来源:origin: selfly/dexcoder-assistant

/**
 * 将sql转换为count查询
 *
 * @param select
 */
protected void sqlToCount(Select select) {
  SelectBody selectBody = select.getSelectBody();
  // 是否能简化count查询
  if (selectBody instanceof PlainSelect && isSimpleCount((PlainSelect) selectBody)) {
    ((PlainSelect) selectBody).setSelectItems(COUNT_ITEM);
  } else {
    PlainSelect plainSelect = new PlainSelect();
    SubSelect subSelect = new SubSelect();
    subSelect.setSelectBody(selectBody);
    subSelect.setAlias(TABLE_ALIAS);
    plainSelect.setFromItem(subSelect);
    plainSelect.setSelectItems(COUNT_ITEM);
    select.setSelectBody(plainSelect);
  }
}

代码示例来源:origin: com.dexcoder/dexcoder-dal-spring

/**
 * 将sql转换为count查询
 *
 * @param select
 */
protected void sqlToCount(Select select) {
  SelectBody selectBody = select.getSelectBody();
  // 是否能简化count查询
  if (selectBody instanceof PlainSelect && isSimpleCount((PlainSelect) selectBody)) {
    ((PlainSelect) selectBody).setSelectItems(COUNT_ITEM);
  } else {
    PlainSelect plainSelect = new PlainSelect();
    SubSelect subSelect = new SubSelect();
    subSelect.setSelectBody(selectBody);
    subSelect.setAlias(TABLE_ALIAS);
    plainSelect.setFromItem(subSelect);
    plainSelect.setSelectItems(COUNT_ITEM);
    select.setSelectBody(plainSelect);
  }
}

代码示例来源:origin: com.hand.hap.cloud/hap-mybatis-mapper-starter

newSelectBody.setFromItem(fromItem);
newSelect.setSelectBody(newSelectBody);
if (isNotEmptyList(select.getWithItemsList())) {
  newSelect.setWithItemsList(select.getWithItemsList());

代码示例来源:origin: Sunybyjava/shoppingMall

/**
 * 将sql转换为count查询
 *
 * @param select
 */
public void sqlToCount(Select select) {
  SelectBody selectBody = select.getSelectBody();
  // select中包含参数时在else中处理
  // select中包含group by时在else中处理
  if (selectBody instanceof PlainSelect
      && !selectItemsHashParameters(((PlainSelect) selectBody).getSelectItems())
      && ((PlainSelect) selectBody).getGroupByColumnReferences() == null) {
    ((PlainSelect) selectBody).setSelectItems(COUNT_ITEM);
  } else {
    PlainSelect plainSelect = new PlainSelect();
    SubSelect subSelect = new SubSelect();
    subSelect.setSelectBody(selectBody);
    subSelect.setAlias(TABLE_ALIAS);
    plainSelect.setFromItem(subSelect);
    plainSelect.setSelectItems(COUNT_ITEM);
    select.setSelectBody(plainSelect);
  }
}

代码示例来源:origin: com.github.pagehelper/pagehelper

newSelectBody.setFromItem(fromItem);
newSelect.setSelectBody(newSelectBody);
if (isNotEmptyList(select.getWithItemsList())) {
  newSelect.setWithItemsList(select.getWithItemsList());

相关文章