Package org.nutz.dao

Examples of org.nutz.dao.Condition


    }

    @Test
    public void test_in_by_int_array() {
        int[] ids = {3, 5, 7};
        Condition c = Cnd.where("id", "iN", ids);
        String exp = "WHERE id IN (3,5,7)";
        assertEquals(exp, c.toSql(null).trim());
    }
View Full Code Here


    public void test_in_by_int_list() {
        List<Integer> list = new ArrayList<Integer>();
        list.add(3);
        list.add(5);
        list.add(7);
        Condition c = Cnd.where("id", "iN", list);
        String exp = "WHERE id IN (3,5,7)";
        assertEquals(exp, c.toSql(null).trim());
    }
View Full Code Here

        assertEquals(exp, c.toSql(null).trim());
    }

    @Test
    public void test_in_by_str_array() {
        Condition c = Cnd.where("nm", "iN", Lang.array("'A'", "B"));
        String exp = "WHERE nm IN ('''A''','B')";
        assertEquals(exp, c.toSql(null).trim());
    }
View Full Code Here

    @Test
    public void test_in_by_str_list() {
        List<String> list = new ArrayList<String>();
        list.add("'A'");
        list.add("B");
        Condition c = Cnd.where("nm", "iN", list);
        String exp = "WHERE nm IN ('''A''','B')";
        assertEquals(exp, c.toSql(null).trim());
    }
View Full Code Here

        assertEquals(exp, c.toSql(null).trim());
    }

    @Test
    public void test_is_null() {
        Condition c = Cnd.where("nm", " is ", null);
        String exp = "WHERE nm IS NULL";
        assertEquals(exp, c.toSql(null).trim());
    }
View Full Code Here

        assertEquals(exp, c.toSql(null).trim());
    }

    @Test
    public void test_is_not_null() {
        Condition c = Cnd.where("nm", " is nOT ", null);
        String exp = "WHERE nm IS NOT NULL";
        assertEquals(exp, c.toSql(null).trim());
    }
View Full Code Here

        assertEquals(exp, c.toSql(null).trim());
    }

    @Test
    public void test_not_in() {
        Condition c = Cnd.where("nm", " Not iN ", new int[]{1, 2, 3});
        String exp = "WHERE nm NOT IN (1,2,3)";
        assertEquals(exp, c.toSql(null).trim());
    }
View Full Code Here

    }

    @Test
    public void test_count_with_entity() {
        insertRecords(8);
        int re = dao.count(Pet.class, new Condition() {
            public String toSql(Entity<?> entity) {
                return entity.getField("nickName").getColumnName() + " IN ('alias_5','alias_6')";
            }
        });
        assertEquals(2, re);
View Full Code Here

    }

    @Test
    public void test_count_with_entity() {
        insertRecords(8);
        int re = dao.count(Pet.class, new Condition() {
            public String toSql(Entity<?> entity) {
                return entity.getField("nickName").getColumnName()
                       + " IN ('alias_5','alias_6')";
            }
        });
View Full Code Here

    @Test
    public void test_segment() {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("name", "比尔盖茨");
        map.put("age", 50);
        Condition c1 = Cnd.wrap("name='${name}' AND age>${age}", map);
        assertEquals("name='比尔盖茨' AND age>50", c1.toSql(en));

        Worker worker = new Worker();
        worker.name = "老板";
        worker.age = 30;
        Condition c2 = Cnd.wrap("name like'${name}%' AND age>${age}", worker);
        assertEquals("name like'老板%' AND age>30", c2.toSql(en));
    }
View Full Code Here

TOP

Related Classes of org.nutz.dao.Condition

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.