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


Java Column类代码示例

本文整理汇总了Java中net.sf.jsqlparser.schema.Column的典型用法代码示例。如果您正苦于以下问题:Java Column类的具体用法?Java Column怎么用?Java Column使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Column类属于net.sf.jsqlparser.schema包,在下文中一共展示了Column类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createUpdateMutation

import net.sf.jsqlparser.schema.Column; //导入依赖的package包/类
private Mutation createUpdateMutation(Update update, boolean generateParameterMetaData) throws SQLException
{
	if (update.getTables().isEmpty())
		throw new CloudSpannerSQLException("No table found in update statement", Code.INVALID_ARGUMENT);
	if (update.getTables().size() > 1)
		throw new CloudSpannerSQLException("Update statements for multiple tables at once are not supported",
				Code.INVALID_ARGUMENT);
	String table = unquoteIdentifier(update.getTables().get(0).getFullyQualifiedName());
	getParameterStore().setTable(table);
	List<Expression> expressions = update.getExpressions();
	WriteBuilder builder = Mutation.newUpdateBuilder(table);
	int index = 0;
	for (Column col : update.getColumns())
	{
		String columnName = unquoteIdentifier(col.getFullyQualifiedName());
		expressions.get(index).accept(new ValueBinderExpressionVisitorAdapter<>(getParameterStore(),
				builder.set(columnName), columnName));
		index++;
	}
	visitUpdateWhereClause(update.getWhere(), builder, generateParameterMetaData);

	return builder.build();
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:24,代码来源:CloudSpannerPreparedStatement.java

示例2: visitDeleteWhereClause

import net.sf.jsqlparser.schema.Column; //导入依赖的package包/类
private void visitDeleteWhereClause(Expression where, DeleteKeyBuilder keyBuilder,
		boolean generateParameterMetaData) throws SQLException
{
	if (where != null)
	{
		DMLWhereClauseVisitor whereClauseVisitor = new DMLWhereClauseVisitor(getParameterStore())
		{

			@Override
			protected void visitExpression(Column col, Expression expression)
			{
				String columnName = unquoteIdentifier(col.getFullyQualifiedName());
				keyBuilder.set(columnName);
				expression.accept(
						new KeyBuilderExpressionVisitorAdapter(getParameterStore(), columnName, keyBuilder));
			}

		};
		where.accept(whereClauseVisitor);
		if (!generateParameterMetaData && !whereClauseVisitor.isValid())
		{
			throw new CloudSpannerSQLException(INVALID_WHERE_CLAUSE_DELETE_MESSAGE, Code.INVALID_ARGUMENT);
		}
	}
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:26,代码来源:CloudSpannerPreparedStatement.java

示例3: isSingleRowWhereClause

import net.sf.jsqlparser.schema.Column; //导入依赖的package包/类
private boolean isSingleRowWhereClause(TableKeyMetaData table, Expression where)
{
	if (where != null)
	{
		SingleRowWhereClauseValidator validator = new SingleRowWhereClauseValidator(table);
		DMLWhereClauseVisitor whereClauseVisitor = new DMLWhereClauseVisitor(getParameterStore())
		{

			@Override
			protected void visitExpression(Column col, Expression expression)
			{
				String columnName = unquoteIdentifier(col.getFullyQualifiedName());
				validator.set(columnName);
				expression.accept(
						new SingleRowWhereClauseValidatorExpressionVisitorAdapter(getParameterStore(), validator));
			}

		};
		where.accept(whereClauseVisitor);
		return whereClauseVisitor.isValid() && validator.isValid();
	}
	return false;
}
 
开发者ID:olavloite,项目名称:spanner-jdbc,代码行数:24,代码来源:CloudSpannerPreparedStatement.java

示例4: sqlToCount

import net.sf.jsqlparser.schema.Column; //导入依赖的package包/类
/**
 * 将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);
    }
}
 
开发者ID:ChenAt,项目名称:common-dao,代码行数:23,代码来源:CountSqlParser.java

示例5: visit

import net.sf.jsqlparser.schema.Column; //导入依赖的package包/类
@Override
public void visit(PivotXml pivot) {
    List<Column> forColumns = pivot.getForColumns();
    buffer.append(" PIVOT XML (")
            .append(PlainSelect.getStringList(pivot.getFunctionItems()))
            .append(" FOR ")
            .append(PlainSelect.getStringList(forColumns, true, forColumns != null && forColumns.size() > 1))
            .append(" IN (");
    if (pivot.isInAny()) {
        buffer.append("ANY");
    } else if (pivot.getInSelect() != null) {
        buffer.append(pivot.getInSelect());
    } else {
        buffer.append(PlainSelect.getStringList(pivot.getInItems()));
    }
    buffer.append("))");
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:18,代码来源:SelectDeParser.java

示例6: visit

import net.sf.jsqlparser.schema.Column; //导入依赖的package包/类
@Override
public void visit(Column tableColumn) {
    final Table table = tableColumn.getTable();
    String tableName = null;
    if (table != null) {
        if (table.getAlias() != null) {
            tableName = table.getAlias().getName();
        } else {
            tableName = table.getFullyQualifiedName();
        }
    }
    if (tableName != null && !tableName.isEmpty()) {
        buffer.append(tableName).append(".");
    }

    buffer.append(tableColumn.getColumnName());
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:18,代码来源:ExpressionDeParser.java

示例7: addRowNumber

import net.sf.jsqlparser.schema.Column; //导入依赖的package包/类
/**
 * 最外层的SQL查询需要增加ROW_NUMBER()
 *
 * @param plainSelect
 */
private void addRowNumber(PlainSelect plainSelect, String orderBy) {
    //增加ROW_NUMBER()
    StringBuilder orderByBuilder = new StringBuilder();
    orderByBuilder.append("ROW_NUMBER() OVER (");
    if (isNotEmptyString(orderBy)) {
        //使用设置的值
        orderByBuilder.append(orderBy);
    } else if (isNotEmptyList(plainSelect.getOrderByElements())) {
        //注意:order by别名的时候有错,由于没法判断一个列是否为别名,所以不能解决
        orderByBuilder.append(PlainSelect.orderByToString(false, plainSelect.getOrderByElements()));
    } else {
        throw new RuntimeException("请您指定order by参数或者在sql中包含order by语句!");
    }
    //需要把改orderby清空
    if (isNotEmptyList(plainSelect.getOrderByElements())) {
        plainSelect.setOrderByElements(null);
    }
    orderByBuilder.append(") ");
    orderByBuilder.append(PAGE_ROW_NUMBER);
    Column orderByColumn = new Column(orderByBuilder.toString());
    plainSelect.getSelectItems().add(0, new SelectExpressionItem(orderByColumn));
}
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:28,代码来源:SqlServer.java

示例8: saveJoinCondition

import net.sf.jsqlparser.schema.Column; //导入依赖的package包/类
/**
 * 举例 left join tab2 on tab1.a = tab2.A
 *
 * @param joinTableType   tab2_left
 * @param righExpEqualsTo tab1.a = tab2.A
 */
public void saveJoinCondition(String joinTableType, EqualsTo righExpEqualsTo) {
    //region 保存至JoinConditon
    Column leftCol = (Column) righExpEqualsTo.getLeftExpression();
    Column rightCol = (Column) righExpEqualsTo.getRightExpression();
    TCItem leftTCItem = new TCItem();
    leftTCItem.setColName(leftCol.getColumnName());
    leftTCItem.setTableName(leftCol.getTable().getName());
    TCItem rightTCItem = new TCItem();
    rightTCItem.setColName(rightCol.getColumnName());
    rightTCItem.setTableName(rightCol.getTable().getName());

    JoinTwoTable joinTwoTable = new JoinTwoTable();
    joinTwoTable.setTcItemLeft(leftTCItem);
    joinTwoTable.setTcItemRight(rightTCItem);
    JoinCondition.linkTablemap.put(joinTableType, joinTwoTable);
    //endregion
}
 
开发者ID:bigdataFlySQL,项目名称:SQLonStorm,代码行数:24,代码来源:ParsingSQL.java

示例9: getGroups

import net.sf.jsqlparser.schema.Column; //导入依赖的package包/类
/**
     * 解析group by的语义,并保存到GoupBy 中
     *
     * @param defalutTable 默认的表名
     * @param plainSelect  SQL
     */
    private void getGroups(String defalutTable, PlainSelect plainSelect) {
        List<Expression> groupExps = plainSelect.getGroupByColumnReferences();
        if (groupExps != null) {
            for (Expression item : groupExps) {
                Column column = (Column) item;
                TCItem tcItem = new TCItem();
                tcItem.setColName(column.getColumnName());
                if (column.getTable().getName() == null || column.getTable().getName().isEmpty()) {
                    tcItem.setTableName(defalutTable);
                } else {
                    tcItem.setTableName(column.getTable().getName());
                }
                GroupBy.groupList.add(tcItem);
            }
        }
//        assertEquals(2,GroupBy.groupList.size());
    }
 
开发者ID:bigdataFlySQL,项目名称:SQLonStorm,代码行数:24,代码来源:ParsingSQL.java

示例10: getType

import net.sf.jsqlparser.schema.Column; //导入依赖的package包/类
/**
 * Get type
 * @param c The connection
 * @param column The column
 * @param query The query
 * @return The value
 */
private static Integer getType(Connection c, Column column, String query) throws Exception
{
   String tableName = column.getTable().getName();

   if (tableName != null && aliases.containsKey(tableName))
      tableName = aliases.get(tableName);

   if (tableName == null)
      tableName = currentTableName;

   tableName = tableName.toLowerCase();

   Map<String, Integer> tableData = tables.get(tableName);

   if (tableData == null)
   {
      getUsedTables(c, query);
      tableData = tables.get(tableName);
   }

   return tableData.get(column.getColumnName().toLowerCase());
}
 
开发者ID:jesperpedersen,项目名称:postgres-tools,代码行数:30,代码来源:QueryAnalyzer.java

示例11: visit

import net.sf.jsqlparser.schema.Column; //导入依赖的package包/类
@Override
public void visit(Insert insert) {
    this.getStack().push(new FrameContext());
    ShardRouteConfig routeConfig = shardRouter.getRouteConfig(insert.getTable().getSchemaName(),
                                                              insert.getTable().getName());
    if (routeConfig != null) {
        TableWrapper table = new TableWrapper(insert.getTable(), routeConfig);
        addRoutedTableIntoContext(table, routeConfig, false);
        List<Column> columns = insert.getColumns();
        if (columns != null) {
            ExpressionList expressionList = (ExpressionList) insert.getItemsList();
            List<Expression> valueList = expressionList.getExpressions();
            for (int i = 0; i < columns.size(); i++) {
                Column column = columns.get(i);
                TableWrapper tab = getTableFromContext(column);
                if (tab != null) {
                    Expression expression = valueList.get(i);
                    routeTable(tab, column, expression);
                }
            }
        }
    }
    super.visit(insert);
    afterVisitBaseStatement();
}
 
开发者ID:hellojavaer,项目名称:ddal,代码行数:26,代码来源:JSQLParserAdapter.java

示例12: getRouteValue

import net.sf.jsqlparser.schema.Column; //导入依赖的package包/类
private Object getRouteValue(Column column, Expression obj) {
    if (obj == null) {
        return null;
    }
    if (obj instanceof LongValue) {
        return ((LongValue) obj).getValue();
    } else if (obj instanceof StringValue) {
        return ((StringValue) obj).getValue();
    } else if (obj instanceof HexValue) {
        return Long.parseLong(((HexValue) obj).getValue(), 16);
    } else if (obj instanceof DateValue) {
        return ((DateValue) obj).getValue();
    } else if (obj instanceof DoubleValue) {
        return ((DoubleValue) obj).getValue();
    } else if (obj instanceof TimeValue) {
        return ((TimeValue) obj).getValue();
    } else if (obj instanceof TimestampValue) {
        return ((TimestampValue) obj).getValue();
    } else {// NullValue
        throw new UnsupportedSQLParameterTypeException("Type '" + obj.getClass()
                                                       + "' is not supported for shard value '" + column.toString()
                                                       + "'. Sql is [" + sql + "]");
    }
}
 
开发者ID:hellojavaer,项目名称:ddal,代码行数:25,代码来源:JSQLParserAdapter.java

示例13: computeNewValue

import net.sf.jsqlparser.schema.Column; //导入依赖的package包/类
@Override
public byte[] computeNewValue(Record previous, StatementEvaluationContext context, TableContext tableContext) throws StatementExecutionException {
    Map<String, Object> res = previous != null ? new HashMap<>(previous.toBean(table)) : new HashMap<>();
    DataAccessor bean = previous != null ? previous.getDataAccessor(table) : DataAccessor.NULL;
    for (int i = 0; i < columns.size(); i++) {
        CompiledSQLExpression e = expressions.get(i);
        String columnName = columns.get(i);
        herddb.model.Column column = table.getColumn(columnName);
        if (column == null) {
            throw new StatementExecutionException("unknown column " + columnName + " in table " + table.name);
        }
        columnName = column.name;
        Object value = RecordSerializer.convert(column.type, e.evaluate(bean, context));
        res.put(columnName, value);
    }
    return RecordSerializer.toRecord(res, table).value.data;
}
 
开发者ID:diennea,项目名称:herddb,代码行数:18,代码来源:SQLRecordFunction.java

示例14: processInsert

import net.sf.jsqlparser.schema.Column; //导入依赖的package包/类
/**
 * <p>
 * insert 语句处理
 * </p>
 */
@Override
public void processInsert(Insert insert) {
    if (this.tenantHandler.doTableFilter(insert.getTable().getName())) {
        // 过滤退出执行
        return;
    }
    insert.getColumns().add(new Column(this.tenantHandler.getTenantIdColumn()));
    if (insert.getSelect() != null) {
        processPlainSelect((PlainSelect) insert.getSelect().getSelectBody(), true);
    } else if (insert.getItemsList() != null) {
        ((ExpressionList) insert.getItemsList()).getExpressions().add(tenantHandler.getTenantId());
    } else {
        throw new MybatisPlusException("Failed to process multiple-table update, please exclude the tableName or statementId");
    }
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:21,代码来源:TenantSqlParser.java

示例15: processPlainSelect

import net.sf.jsqlparser.schema.Column; //导入依赖的package包/类
/**
 * <p>
 * 处理 PlainSelect
 * </p>
 *
 * @param plainSelect
 * @param addColumn   是否添加租户列,insert into select语句中需要
 */
protected void processPlainSelect(PlainSelect plainSelect, boolean addColumn) {
    FromItem fromItem = plainSelect.getFromItem();
    if (fromItem instanceof Table) {
        Table fromTable = (Table) fromItem;
        if (this.tenantHandler.doTableFilter(fromTable.getName())) {
            // 过滤退出执行
            return;
        }
        plainSelect.setWhere(builderExpression(plainSelect.getWhere(), fromTable));
        if (addColumn) {
            plainSelect.getSelectItems().add(new SelectExpressionItem(new Column(this.tenantHandler.getTenantIdColumn())));
        }
    } else {
        processFromItem(fromItem);
    }
    List<Join> joins = plainSelect.getJoins();
    if (joins != null && joins.size() > 0) {
        for (Join join : joins) {
            processJoin(join);
            processFromItem(join.getRightItem());
        }
    }
}
 
开发者ID:baomidou,项目名称:mybatis-plus,代码行数:32,代码来源:TenantSqlParser.java


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