net.sf.jsqlparser.expression.JdbcParameter Java Examples

The following examples show how to use net.sf.jsqlparser.expression.JdbcParameter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CloudSpannerPreparedStatement.java    From spanner-jdbc with MIT License 6 votes vote down vote up
private void setWhereParameters(Expression where,
    com.google.cloud.spanner.Statement.Builder builder) {
  if (where != null) {
    where.accept(new ExpressionVisitorAdapter() {
      private String currentCol = null;

      @Override
      public void visit(Column col) {
        currentCol = unquoteIdentifier(col.getFullyQualifiedName());
      }

      @Override
      public void visit(JdbcParameter parameter) {
        parameter.accept(new ValueBinderExpressionVisitorAdapter<>(getParameterStore(),
            builder.bind("p" + parameter.getIndex()), currentCol));
        currentCol = null;
      }

      @Override
      public void visit(SubSelect subSelect) {
        setSelectParameters(subSelect.getSelectBody(), builder);
      }

    });
  }
}
 
Example #2
Source File: SQLRecordPredicate.java    From herddb with Apache License 2.0 5 votes vote down vote up
static boolean isConstant(Expression exp) {
    return exp instanceof StringValue
            || exp instanceof LongValue
            || exp instanceof NullValue
            || exp instanceof TimestampValue
            || exp instanceof JdbcParameter;
}
 
Example #3
Source File: PlaceholderExpressionConverter.java    From sqlhelper with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public JdbcParameter toJSqlParserExpression(PlaceholderExpression expression) {
    return new JdbcParameter();
}
 
Example #4
Source File: PlaceholderExpressionConverter.java    From sqlhelper with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public PlaceholderExpression fromJSqlParserExpression(JdbcParameter expression) {
    return null;
}
 
Example #5
Source File: PlaceholderExpressionConverter.java    From sqlhelper with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Class<JdbcParameter> getJSqlParserExpressionClass() {
    return JdbcParameter.class;
}
 
Example #6
Source File: ExpressionVisitorImpl.java    From DataPermissionHelper with Apache License 2.0 4 votes vote down vote up
@Override
public void visit(JdbcParameter jdbcParameter) {
}
 
Example #7
Source File: AbstractSpannerExpressionVisitorAdapter.java    From spanner-jdbc with MIT License 4 votes vote down vote up
@Override
public void visit(JdbcParameter parameter) {
  Object value = parameterStore.getParameter(parameter.getIndex());
  parameterStore.setColumn(parameter.getIndex(), column);
  setValue(value, parameterStore.getType(parameter.getIndex()));
}
 
Example #8
Source File: DMLWhereClauseVisitor.java    From spanner-jdbc with MIT License 4 votes vote down vote up
@Override
public void visit(JdbcParameter parameter) {
  visitExpression(col, parameter);
}
 
Example #9
Source File: DDLSQLPlanner.java    From herddb with Apache License 2.0 4 votes vote down vote up
private static Object resolveValue(Expression expression, boolean allowColumn) throws StatementExecutionException {
    if (expression instanceof JdbcParameter) {
        throw new StatementExecutionException("jdbcparameter expression not usable in this query");
    } else if (allowColumn && expression instanceof net.sf.jsqlparser.schema.Column) {
        // this is only for supporting back ticks in DDL
        return fixMySqlBackTicks(((net.sf.jsqlparser.schema.Column) expression).getColumnName());
    } else if (expression instanceof StringValue) {
        return ((StringValue) expression).getValue();
    } else if (expression instanceof LongValue) {
        return ((LongValue) expression).getValue();
    } else if (expression instanceof TimestampValue) {
        return ((TimestampValue) expression).getValue();
    } else if (expression instanceof SignedExpression) {
        SignedExpression se = (SignedExpression) expression;
        switch (se.getSign()) {
            case '+': {
                return resolveValue(se.getExpression(), allowColumn);
            }
            case '-': {
                Object value = resolveValue(se.getExpression(), allowColumn);
                if (value == null) {
                    return null;
                }
                if (value instanceof Integer) {
                    return -1L * ((Integer) value);
                } else if (value instanceof Long) {
                    return -1L * ((Long) value);
                } else {
                    throw new StatementExecutionException(
                            "unsupported value type " + expression.getClass() + " with sign " + se.getSign() + " on value " + value + " of type " + value.
                            getClass());
                }
            }
            default:
                throw new StatementExecutionException(
                        "unsupported value type " + expression.getClass() + " with sign " + se.getSign());
        }

    } else {
        throw new StatementExecutionException("unsupported value type " + expression.getClass());
    }
}
 
Example #10
Source File: ImmutableExpressionsCache.java    From herddb with Apache License 2.0 4 votes vote down vote up
public static JdbcParameter internOrFixJdbcParameterExpression(JdbcParameter param) {
    ImmutableJdbcParameter res = IMMUTABLE_JDBC_PARAMETERS.get(param.getIndex());
    return res != null ? res : param;
}
 
Example #11
Source File: CTEToNestedQueryConverter.java    From quetzal with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void visit(JdbcParameter jdbcParameter) {
	clear();
	defaultTopLevelProcessing(jdbcParameter);
}