本文整理汇总了Java中org.h2.command.dml.Select类的典型用法代码示例。如果您正苦于以下问题:Java Select类的具体用法?Java Select怎么用?Java Select使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Select类属于org.h2.command.dml包,在下文中一共展示了Select类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateAggregate
import org.h2.command.dml.Select; //导入依赖的package包/类
@Override
public void updateAggregate(Session session) {
Value now = columnResolver.getValue(column);
Select select = columnResolver.getSelect();
if (select == null) {
throw DbException.get(ErrorCode.MUST_GROUP_BY_COLUMN_1, getSQL());
}
HashMap<Expression, Object> values = select.getCurrentGroup();
if (values == null) {
// this is a different level (the enclosing query)
return;
}
Value v = (Value) values.get(this);
if (v == null) {
values.put(this, now);
} else {
if (!database.areEqual(now, v)) {
throw DbException.get(ErrorCode.MUST_GROUP_BY_COLUMN_1, getSQL());
}
}
}
示例2: getValue
import org.h2.command.dml.Select; //导入依赖的package包/类
@Override
public Value getValue(Session session) {
Select select = columnResolver.getSelect();
if (select != null) {
HashMap<Expression, Object> values = select.getCurrentGroup();
if (values != null) {
Value v = (Value) values.get(this);
if (v != null) {
return v;
}
}
}
Value value = columnResolver.getValue(column);
if (value == null) {
columnResolver.getValue(column);
throw DbException.get(ErrorCode.MUST_GROUP_BY_COLUMN_1, getSQL());
}
return value;
}
示例3: getFields
import org.h2.command.dml.Select; //导入依赖的package包/类
private DataField[] getFields(Select select, DataField[] fields) {
ArrayList<DataField> toReturn = new ArrayList<DataField>();
try {
for (int i=0;i<select.getColumnCount();i++) {
String name = select.queryMeta().getColumnName(i);
if (name.equalsIgnoreCase("timed") || name.equalsIgnoreCase("pk") )
continue;
String gsnType = null;
for (int j=0;j<fields.length;j++) {
if (fields[j].getName().equalsIgnoreCase(name)) {
gsnType=fields[j].getType();
toReturn.add( new DataField(name,gsnType));
break;
}
}
}
return toReturn.toArray(new DataField[] {});
}catch (Exception e) {
logger.debug(e.getMessage(),e);
return new DataField[0];
}
}
示例4: TableFilter
import org.h2.command.dml.Select; //导入依赖的package包/类
/**
* Create a new table filter object.
*
* @param session the session
* @param table the table from where to read data
* @param alias the alias name
* @param rightsChecked true if rights are already checked
* @param select the select statement
*/
public TableFilter(Session session, Table table, String alias,
boolean rightsChecked, Select select) {
this.session = session;
this.table = table;
this.alias = alias;
this.select = select;
this.cursor = new IndexCursor(this);
if (!rightsChecked) {
session.getUser().checkRight(table, Right.SELECT);
}
hashCode = session.nextObjectId();
}
示例5: parseSelectSub
import org.h2.command.dml.Select; //导入依赖的package包/类
private Query parseSelectSub() {
if (readIf("(")) {
Query command = parseSelectUnion();
read(")");
return command;
}
Select select = parseSelectSimple();
return select;
}
示例6: parseJoinTableFilter
import org.h2.command.dml.Select; //导入依赖的package包/类
private void parseJoinTableFilter(TableFilter top, final Select command) {
top = readJoin(top, command, false, top.isJoinOuter());
command.addTableFilter(top, true);
boolean isOuter = false;
while (true) {
TableFilter n = top.getNestedJoin();
if (n != null) {
n.visit(new TableFilterVisitor() {
@Override
public void accept(TableFilter f) {
command.addTableFilter(f, false);
}
});
}
TableFilter join = top.getJoin();
if (join == null) {
break;
}
isOuter = isOuter | join.isJoinOuter();
if (isOuter) {
command.addTableFilter(join, false);
} else {
// make flat so the optimizer can work better
Expression on = join.getJoinCondition();
if (on != null) {
command.addCondition(on);
}
join.removeJoinCondition();
top.removeJoin();
command.addTableFilter(join, true);
}
top = join;
}
}
示例7: parseValues
import org.h2.command.dml.Select; //导入依赖的package包/类
private Select parseValues() {
Select command = new Select(session);
currentSelect = command;
TableFilter filter = parseValuesTable();
ArrayList<Expression> list = New.arrayList();
list.add(new Wildcard(null, null));
command.setExpressions(list);
command.addTableFilter(filter, true);
command.init();
return command;
}
示例8: parseQuery
import org.h2.command.dml.Select; //导入依赖的package包/类
/**
* @param qry Query.
* @return Parsed query AST.
*/
private GridSqlQuery parseQuery(Query qry) {
if (qry instanceof Select)
return parseSelect((Select)qry);
if (qry instanceof SelectUnion)
return parseUnion((SelectUnion)qry);
throw new UnsupportedOperationException("Unknown query type: " + qry);
}
示例9: collectOptimizedTableFiltersOrder
import org.h2.command.dml.Select; //导入依赖的package包/类
/**
* @param qry Query.
*/
private void collectOptimizedTableFiltersOrder(Query qry) {
if (qry instanceof SelectUnion) {
collectOptimizedTableFiltersOrder(((SelectUnion)qry).getLeft());
collectOptimizedTableFiltersOrder(((SelectUnion)qry).getRight());
}
else {
Select select = (Select)qry;
TableFilter filter = select.getTopTableFilter();
int i = 0;
do {
assert0(filter != null, select);
assert0(filter.getNestedJoin() == null, select);
// Here all the table filters must have generated unique aliases,
// thus we can store them in the same map for all the subqueries.
optimizedTableFilterOrder.put(filter.getTableAlias(), i++);
Table tbl = filter.getTable();
// Go down and collect inside of optimized subqueries.
if (tbl instanceof TableView) {
ViewIndex viewIdx = (ViewIndex)filter.getIndex();
collectOptimizedTableFiltersOrder(viewIdx.getQuery());
}
filter = filter.getJoin();
}
while (filter != null);
}
}
示例10: validateQuery
import org.h2.command.dml.Select; //导入依赖的package包/类
/**
* Returns null if the validation fails. Returns the table name used in the query if the validation succeeds.
* @param query to validate.
* @return Null if the validation fails. The name of the table if the validation succeeds.
*/
public String validateQuery(String query) {
Select select = queryToSelect(query);
if (select ==null)
return null;
if ((select.getTables().size() != 1) || (select.getTopFilters().size()!=1) || select.isQuickAggregateQuery() )
return null;
return select.getTables().iterator().next().getName();
}
示例11: extractSelectColumns
import org.h2.command.dml.Select; //导入依赖的package包/类
public DataField[] extractSelectColumns(String query, VSensorConfig vSensorConfig) {
Select select = queryToSelect(query);
if (select ==null)
return new DataField[0];
return getFields(select,vSensorConfig.getOutputStructure());
}
示例12: addPkField
import org.h2.command.dml.Select; //导入依赖的package包/类
public static String addPkField(String query) {
logger.debug("< QUERY IN: " + query);
try {
SQLValidator sv = getInstance();
Select select = sv.queryToSelect(query);
if (select == null)
return query;
boolean hasPk = false;
boolean hasWildCard = false;
for (int i=0;i<select.getColumnCount();i++) {
String name = select.queryMeta().getColumnName(i);
if (name.equalsIgnoreCase("*")) {
hasWildCard = true;
break;
}
if (name.equalsIgnoreCase("pk")) {
hasPk = true;
break;
}
}
//
if (! hasPk && !hasWildCard) {
int is = query.toUpperCase().indexOf("SELECT");
query = new StringBuilder(query.substring(is,is+6))
.append(" pk, ")
.append(query.substring(is+7)).toString();
}
}
catch (Exception e) {
logger.error(e.getMessage(), e);
}
logger.debug("> QUERY OUT: " + query);
return query;
}
示例13: JavaAggregate
import org.h2.command.dml.Select; //导入依赖的package包/类
public JavaAggregate(UserAggregate userAggregate, Expression[] args,
Select select) {
this.userAggregate = userAggregate;
this.args = args;
this.select = select;
}
示例14: getSelect
import org.h2.command.dml.Select; //导入依赖的package包/类
@Override
public Select getSelect() {
return null;
}
示例15: getSelect
import org.h2.command.dml.Select; //导入依赖的package包/类
@Override
public Select getSelect() {
return select;
}