Search in sources :

Example 26 with Value

use of org.seasar.doma.internal.expr.Value in project doma by domaframework.

the class SqlProcessorQuery method addParameter.

public void addParameter(String name, Class<?> type, Object value) {
    assertNotNull(name, type);
    parameters.put(name, new Value(type, value));
}
Also used : Value(org.seasar.doma.internal.expr.Value)

Example 27 with Value

use of org.seasar.doma.internal.expr.Value in project doma by domaframework.

the class SqlBatchModifyQuery method addParameter.

public void addParameter(String name, Class<?> type, List<?> values) {
    assertNotNull(name, type);
    assertNotNull(values);
    List<Value> valueList = new ArrayList<>();
    for (Object value : values) {
        valueList.add(new Value(type, value));
    }
    if (parameterSize == -1) {
        parameterSize = valueList.size();
    } else {
        assertEquals(parameterSize, valueList.size());
    }
    parameters.put(name, valueList);
}
Also used : Value(org.seasar.doma.internal.expr.Value) ArrayList(java.util.ArrayList)

Example 28 with Value

use of org.seasar.doma.internal.expr.Value in project doma by domaframework.

the class AbstractSelectQuery method addParameter.

public void addParameter(String name, Class<?> type, Object value) {
    assertNotNull(name, type);
    parameters.put(name, new Value(type, value));
}
Also used : Value(org.seasar.doma.internal.expr.Value)

Example 29 with Value

use of org.seasar.doma.internal.expr.Value in project doma by domaframework.

the class SqlBatchModifyQuery method prepareSql.

protected void prepareSql() {
    sqls = new ArrayList<>();
    IntStream.rangeClosed(0, parameterSize - 1).forEach(i -> {
        @SuppressWarnings("serial") Map<String, Value> map = new LinkedHashMap<String, Value>() {

            {
                parameters.forEach((key, value) -> put(key, value.get(i)));
            }
        };
        ExpressionEvaluator evaluator = new ExpressionEvaluator(map, config.getDialect().getExpressionFunctions(), config.getClassHelper());
        NodePreparedSqlBuilder sqlBuilder = new NodePreparedSqlBuilder(config, kind, null, evaluator, sqlLogType);
        PreparedSql sql = sqlBuilder.build(sqlNode, this::comment);
        sqls.add(sql);
    });
}
Also used : PreparedSql(org.seasar.doma.jdbc.PreparedSql) Value(org.seasar.doma.internal.expr.Value) NodePreparedSqlBuilder(org.seasar.doma.internal.jdbc.sql.NodePreparedSqlBuilder) ExpressionEvaluator(org.seasar.doma.internal.expr.ExpressionEvaluator) LinkedHashMap(java.util.LinkedHashMap)

Example 30 with Value

use of org.seasar.doma.internal.expr.Value in project doma by domaframework.

the class SqlFileBatchModifyQuery method prepareSql.

protected void prepareSql() {
    Value value = new Value(elementClass, currentEntity);
    ExpressionEvaluator evaluator = new ExpressionEvaluator(Collections.singletonMap(parameterName, value), config.getDialect().getExpressionFunctions(), config.getClassHelper());
    NodePreparedSqlBuilder sqlBuilder = new NodePreparedSqlBuilder(config, kind, sqlFile.getPath(), evaluator, sqlLogType, this::expandColumns, this::populateValues);
    PreparedSql sql = sqlBuilder.build(sqlFile.getSqlNode(), this::comment);
    sqls.add(sql);
}
Also used : PreparedSql(org.seasar.doma.jdbc.PreparedSql) Value(org.seasar.doma.internal.expr.Value) NodePreparedSqlBuilder(org.seasar.doma.internal.jdbc.sql.NodePreparedSqlBuilder) ExpressionEvaluator(org.seasar.doma.internal.expr.ExpressionEvaluator)

Aggregations

Value (org.seasar.doma.internal.expr.Value)54 ExpressionEvaluator (org.seasar.doma.internal.expr.ExpressionEvaluator)49 Test (org.junit.jupiter.api.Test)47 SqlNode (org.seasar.doma.jdbc.SqlNode)41 PreparedSql (org.seasar.doma.jdbc.PreparedSql)38 BigDecimal (java.math.BigDecimal)11 List (java.util.List)11 ArrayList (java.util.ArrayList)10 JdbcException (org.seasar.doma.jdbc.JdbcException)8 NodePreparedSqlBuilder (org.seasar.doma.internal.jdbc.sql.NodePreparedSqlBuilder)5 SqlParser (org.seasar.doma.internal.jdbc.sql.SqlParser)3 EvaluationResult (org.seasar.doma.internal.expr.EvaluationResult)2 PhoneNumber (example.domain.PhoneNumber)1 LinkedHashMap (java.util.LinkedHashMap)1 MockConfig (org.seasar.doma.internal.jdbc.mock.MockConfig)1 AnonymousNode (org.seasar.doma.internal.jdbc.sql.node.AnonymousNode)1 BindVariableNode (org.seasar.doma.internal.jdbc.sql.node.BindVariableNode)1 EndNode (org.seasar.doma.internal.jdbc.sql.node.EndNode)1 ForNode (org.seasar.doma.internal.jdbc.sql.node.ForNode)1 FromClauseNode (org.seasar.doma.internal.jdbc.sql.node.FromClauseNode)1