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

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


    @Test
    public void detectsUpdate() throws Exception
    {
        String sql = "update PLANET set NAME='Mercury' where ID=1";
        QueryTemplate queryTemplate = parser.parse(sql);
        assertEquals(QueryType.UPDATE, queryTemplate.getType());
        assertEquals(sql, queryTemplate.getSqlText());
        assertEquals(0, queryTemplate.getInputParams().size());
    }
View Full Code Here


    @Test
    public void detectsUpdatewithLineBreak() throws Exception
    {
        String sql = "update PLANET set NAME='Mercury' \nwhere ID=1";
        QueryTemplate queryTemplate = parser.parse(sql);
        assertEquals(QueryType.UPDATE, queryTemplate.getType());
        assertEquals(sql, queryTemplate.getSqlText());
        assertEquals(0, queryTemplate.getInputParams().size());
    }
View Full Code Here

    @Test
    public void detectsInsert() throws Exception
    {
        String sql = "INSERT INTO PLANET(POSITION, NAME) VALUES (777, 'Mercury')";
        QueryTemplate queryTemplate = parser.parse(sql);
        assertEquals(QueryType.INSERT, queryTemplate.getType());
        assertEquals(sql, queryTemplate.getSqlText());
        assertEquals(0, queryTemplate.getInputParams().size());
    }
View Full Code Here

    @Test
    public void detectsInsertWithLineBreak() throws Exception
    {
        String sql = "INSERT INTO PLANET(\nPOSITION, NAME) VALUES (777, 'Mercury')";
        QueryTemplate queryTemplate = parser.parse(sql);
        assertEquals(QueryType.INSERT, queryTemplate.getType());
        assertEquals(sql, queryTemplate.getSqlText());
        assertEquals(0, queryTemplate.getInputParams().size());
    }
View Full Code Here

    @Test
    public void detectsDelete() throws Exception
    {
        String sql = "delete from PLANET";
        QueryTemplate queryTemplate = parser.parse(sql);
        assertEquals(QueryType.DELETE, queryTemplate.getType());
        assertEquals(sql, queryTemplate.getSqlText());
        assertEquals(0, queryTemplate.getInputParams().size());
    }
View Full Code Here

        final String sqlText = "call testStoredProcedure(?)";

        DbConnection connection = new DbConnectionBuilder().onCalatog(catalog).with(databaseMetaData).build();

        QueryTemplate queryTemplate = new QueryTemplate(sqlText, QueryType.STORE_PROCEDURE_CALL, Collections.<org.mule.module.db.internal.domain.param.QueryParam>singletonList(new DefaultInputQueryParam(1, UnknownDbType.getInstance(), "7", TYPE_COLUMN)));

        DbTypeManager dbTypeManager = new DbTypeManagerBuilder().on(connection).managing(JdbcTypes.INTEGER_DB_TYPE).build();

        StoredProcedureParamTypeResolver paramTypeResolver = new StoredProcedureParamTypeResolver(dbTypeManager);
View Full Code Here

    @Test
    public void detectsDeleteWithLineBreak() throws Exception
    {
        String sql = "delete from PLANET";
        QueryTemplate queryTemplate = parser.parse(sql);
        assertEquals(QueryType.DELETE, queryTemplate.getType());
        assertEquals(sql, queryTemplate.getSqlText());
        assertEquals(0, queryTemplate.getInputParams().size());
    }
View Full Code Here

        DefaultOutputQueryParam param1 = new DefaultOutputQueryParam(0, UnknownDbType.getInstance(), "param1");
        List<QueryParam> params = new LinkedList<QueryParam>();
        params.add(param1);

        QueryTemplate queryTemplate = new QueryTemplate("dummy", QueryType.STORE_PROCEDURE_CALL, params);
        StatementResultIterator iterator = new StatementResultIterator(null, statement, queryTemplate, null, null);

        boolean hasNext = iterator.hasNext();

        assertThat(hasNext, equalTo(true));
View Full Code Here

        DefaultOutputQueryParam param1 = new DefaultOutputQueryParam(1, UnknownDbType.getInstance(), "param1");
        List<QueryParam> params = new LinkedList<QueryParam>();
        params.add(param1);

        QueryTemplate queryTemplate = new QueryTemplate("dummy", QueryType.STORE_PROCEDURE_CALL, params);
        StatementResultIterator iterator = new StatementResultIterator(null, statement, queryTemplate, null, null);

        Object nextResult = iterator.next();

        assertThat(nextResult, is(instanceOf(OutputParamResult.class)));
View Full Code Here

        DefaultOutputQueryParam param2 = new DefaultOutputQueryParam(2, UnknownDbType.getInstance(), "param2");
        List<QueryParam> params = new LinkedList<QueryParam>();
        params.add(param1);
        params.add(param2);

        QueryTemplate queryTemplate = new QueryTemplate("dummy", QueryType.STORE_PROCEDURE_CALL, params);
        StatementResultIterator iterator = new StatementResultIterator(connection, statement, queryTemplate, new NoAutoGeneratedKeyStrategy(), null);

        iterator.next();
        iterator.next();
View Full Code Here

TOP

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

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.