Package org.mule.module.db.internal.domain.query

Examples of org.mule.module.db.internal.domain.query.Query


    }

    @Override
    protected Object executeQuery(DbConnection connection, MuleEvent muleEvent) throws SQLException
    {
        Query query = queryResolver.resolve(connection, muleEvent);

        validateQueryType(query.getQueryTemplate());

        List<List<QueryParamValue>> paramValues = resolveParamSets(muleEvent, query);

        BulkExecutor bulkUpdateExecutor = bulkUpdateExecutorFactory.create();
        return bulkUpdateExecutor.execute(connection, query, paramValues);
View Full Code Here


        {
            QueryTemplate queryTemplate = query.getQueryTemplate();
            String resolvedSqlText = expressionManager.parse(queryTemplate.getSqlText(), muleEvent);
            queryTemplate = queryTemplateParser.parse(resolvedSqlText);

            return new Query(queryTemplate, Collections.<QueryParamValue>emptyList());
        }
        catch (RuntimeException e)
        {
            throw new QueryResolutionException("Error parsing query", e);
        }
View Full Code Here

            Map<Integer, DbType> paramTypes = getParameterTypes(connection, queryTemplate);

            queryTemplate = resolveQueryTemplate(queryTemplate, paramTypes);
        }

        return new Query(queryTemplate, resolvedParams);
    }
View Full Code Here

    @Override
    protected Object executeQuery(DbConnection connection, MuleEvent muleEvent) throws SQLException
    {
        MuleEvent eventToUse = resolveSource(muleEvent);

        Query resolvedQuery = queryResolver.resolve(connection, eventToUse);

        validateQueryType(resolvedQuery.getQueryTemplate());

        return doExecuteQuery(connection, resolvedQuery);
    }
View Full Code Here

        QueryResolver queryResolver = new ParametrizedQueryResolver(resolvedTemplateQuery, paramValueResolver);

        List<QueryParamValue> resolvedParams = Collections.singletonList(new QueryParamValue("param1", "foo"));
        when(paramValueResolver.resolveParams(muleEvent, resolvedTemplateQuery.getParamValues())).thenReturn(resolvedParams);

        Query resolvedQuery = queryResolver.resolve(null, muleEvent);

        assertThat(resolvedTemplateQuery, not(sameInstance(resolvedQuery)));
        assertThat(resolvedTemplateQuery.getQueryTemplate(), sameInstance(resolvedQuery.getQueryTemplate()));
        assertThat(resolvedParams, sameInstance(resolvedQuery.getParamValues()));
        assertThat((String) resolvedParams.get(0).getValue(), equalTo("foo"));
    }
View Full Code Here

        QueryResolver queryResolver = new ParametrizedQueryResolver(unresolvedTemplateQuery, paramValueResolver);

        DbConnection connection = mock(DbConnection.class);
        when(connection.getParamTypes(unresolvedTemplateQuery.getQueryTemplate())).thenReturn(Collections.singletonMap(1, JdbcTypes.INTEGER_DB_TYPE));

        Query resolvedQuery = queryResolver.resolve(connection, muleEvent);

        assertThat(unresolvedTemplateQuery, not(sameInstance(resolvedQuery)));
        assertThat(unresolvedTemplateQuery.getQueryTemplate().getSqlText(), equalTo(resolvedQuery.getQueryTemplate().getSqlText()));
        assertThat(resolvedQuery.getQueryTemplate().getParams().get(0).getType(), equalTo(JdbcTypes.INTEGER_DB_TYPE));
        assertThat(resolvedParams, sameInstance(resolvedQuery.getParamValues()));
        assertThat((String) resolvedParams.get(0).getValue(), equalTo("foo"));
    }
View Full Code Here

                QueryParamValue paramValue = new QueryParamValue("param" + paramIndex++, param);
                queryParamValues.add(paramValue);
            }
        }

        return new Query(template, queryParamValues);
    }
View Full Code Here

        return new Query(template, queryParamValues);
    }

    protected Query createQuery(QueryTemplate template)
    {
        return new Query(template);
    }
View Full Code Here

{

    @Test
    public void resolvesStaticQuery() throws Exception
    {
        Query query = createQuery(createQueryTemplate(STATIC_SQL_TEXT));

        StaticQueryResolver queryResolver = new StaticQueryResolver(query);

        Query resolvedQuery = queryResolver.resolve(null, muleEvent);

        assertThat(query, equalTo(resolvedQuery));
    }
View Full Code Here

        QueryTemplateParser queryTemplateParser = mock(QueryTemplateParser.class);
        when(queryTemplateParser.parse(staticSqlText)).thenReturn(expectedQueryTemplate);

        DynamicQueryResolver queryResolver = new DynamicQueryResolver(query, queryTemplateParser, expressionManager);

        Query resolvedQuery = queryResolver.resolve(null, muleEvent);

        assertThat(expectedQueryTemplate, sameInstance(resolvedQuery.getQueryTemplate()));
    }
View Full Code Here

TOP

Related Classes of org.mule.module.db.internal.domain.query.Query

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.