Search in sources :

Example 6 with UserVariable

use of net.sf.jsqlparser.expression.UserVariable in project jans by JanssenProject.

the class SpannerFilterConverter method buildVariableExpression.

private Expression buildVariableExpression(TableMapping tableMapping, String attributeName, Object attribyteValue, Map<String, ValueWithStructField> queryParameters) throws SearchException {
    StructField structField = getStructField(tableMapping, attributeName);
    String usedAttributeName = attributeName;
    int idx = 0;
    while (queryParameters.containsKey(usedAttributeName) && (idx < 100)) {
        usedAttributeName = attributeName + Integer.toString(idx++);
    }
    queryParameters.put(usedAttributeName, new ValueWithStructField(attribyteValue, structField));
    return new UserVariable(usedAttributeName);
}
Also used : ValueWithStructField(io.jans.orm.cloud.spanner.model.ValueWithStructField) StructField(com.google.cloud.spanner.Type.StructField) UserVariable(net.sf.jsqlparser.expression.UserVariable) ValueWithStructField(io.jans.orm.cloud.spanner.model.ValueWithStructField)

Aggregations

UserVariable (net.sf.jsqlparser.expression.UserVariable)6 ColDataType (net.sf.jsqlparser.statement.create.table.ColDataType)4 Test (org.junit.jupiter.api.Test)4 TypeDefExpr (net.sf.jsqlparser.statement.DeclareStatement.TypeDefExpr)3 ResultSet (com.google.cloud.spanner.ResultSet)1 SpannerException (com.google.cloud.spanner.SpannerException)1 Statement (com.google.cloud.spanner.Statement)1 StructField (com.google.cloud.spanner.Type.StructField)1 ValueWithStructField (io.jans.orm.cloud.spanner.model.ValueWithStructField)1 SearchException (io.jans.orm.exception.operation.SearchException)1 AttributeData (io.jans.orm.model.AttributeData)1 ArrayList (java.util.ArrayList)1 LongValue (net.sf.jsqlparser.expression.LongValue)1 StringValue (net.sf.jsqlparser.expression.StringValue)1 EqualsTo (net.sf.jsqlparser.expression.operators.relational.EqualsTo)1 Column (net.sf.jsqlparser.schema.Column)1 Table (net.sf.jsqlparser.schema.Table)1 ColumnDefinition (net.sf.jsqlparser.statement.create.table.ColumnDefinition)1 Limit (net.sf.jsqlparser.statement.select.Limit)1 PlainSelect (net.sf.jsqlparser.statement.select.PlainSelect)1