Search in sources :

Example 1 with SimpleCriteria

use of org.nutz.dao.util.cri.SimpleCriteria in project nutz by nutzam.

the class QueryTest method query_by_like_ignorecase.

@Test
public void query_by_like_ignorecase() {
    SimpleCriteria cri = Cnd.cri();
    cri.where().andLike("name", "PeT6", true);
    List<Pet> pets = dao.query(Pet.class, cri, dao.createPager(1, 10));
    assertEquals(1, pets.size());
    assertEquals("pet6", pets.get(0).getName());
}
Also used : SimpleCriteria(org.nutz.dao.util.cri.SimpleCriteria) Pet(org.nutz.dao.test.meta.Pet) Test(org.junit.Test)

Example 2 with SimpleCriteria

use of org.nutz.dao.util.cri.SimpleCriteria in project nutz by nutzam.

the class EachTest method each_by_like_ignorecase.

@Test
public void each_by_like_ignorecase() {
    SimpleCriteria cri = Cnd.cri();
    cri.where().andLike("name", "PeT6", true);
    final List<Pet> pets = new ArrayList<Pet>();
    dao.each(Pet.class, cri, dao.createPager(1, 10), new Each<Pet>() {

        public void invoke(int i, Pet pet, int length) {
            pets.add(pet);
        }
    });
    assertEquals(1, pets.size());
    assertEquals("pet6", pets.get(0).getName());
}
Also used : SimpleCriteria(org.nutz.dao.util.cri.SimpleCriteria) ArrayList(java.util.ArrayList) Pet(org.nutz.dao.test.meta.Pet) Test(org.junit.Test)

Example 3 with SimpleCriteria

use of org.nutz.dao.util.cri.SimpleCriteria in project nutz by nutzam.

the class ManyManyLinkField method createCondition.

public Condition createCondition(Object host) {
    SimpleCriteria cri = Cnd.cri();
    cri.where().andInBySql(linkedField.getColumnName(), "SELECT %s FROM %s WHERE %s=%s", toColumnName, this.getRelationName(), fromColumnName, Sqls.formatFieldValue(hostField.getValue(host)));
    return cri;
}
Also used : SimpleCriteria(org.nutz.dao.util.cri.SimpleCriteria)

Aggregations

SimpleCriteria (org.nutz.dao.util.cri.SimpleCriteria)3 Test (org.junit.Test)2 Pet (org.nutz.dao.test.meta.Pet)2 ArrayList (java.util.ArrayList)1