Package com.javaeye.jert.domain.query.impl

Examples of com.javaeye.jert.domain.query.impl.DynamicParameterQuery


        if(QUERY_TYPE_STATIC.equals(queryType)){
            return new StaticQuery(sql);
        }else if(QUERY_TYPE_SIMPLE_PARAMETER.equals(queryType)){
            return new SimpleParameterQuery(sql);
        }else if(QUERY_TYPE_DYNAMIC_PARAMETER.equals(queryType)){
            return new DynamicParameterQuery(sql);
        }else{
            throw new IllegalArgumentException(queryType + " is not supported");
        }
    }
View Full Code Here


    private static final String conditionalSql = "<plain>select * from user_impl where 1 = 1</plain>"
            + "<dynamic type=\"isNotNull\" append-before=\"and age > \" parameter-name=\"age1\"/>"
            + "<dynamic type=\"isNotEmpty\" append-before=\"and age &lt; \" parameter-name=\"age2\"/>";
    public void testConditionalPart() {
        DynamicParameterQuery query = new DynamicParameterQuery(conditionalSql);
        assertEquals("age1", query.getParameterNames().get(0));
        assertEquals("age2", query.getParameterNames().get(1));

        assertEquals("select * from user_impl where 1 = 1", query.getSql(null));

        QueryParameter p1 = new QueryParameter(new ParameterDefinition("age1"));
        QueryParameter p2 = new QueryParameter(new ParameterDefinition("age2"));
        p1.setValue("30");
        p2.setValue("");
       
        assertEquals("select * from user_impl where 1 = 1 and age > ?", query.getSql(new QueryParameter[] { p1, p2 }));

        p2.setValue("50");
        assertEquals("select * from user_impl where 1 = 1 and age > ? and age < ?", query.getSql(new QueryParameter[] { p1, p2 }));

    }
View Full Code Here

TOP

Related Classes of com.javaeye.jert.domain.query.impl.DynamicParameterQuery

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.