本文整理匯總了Java中com.j256.ormlite.stmt.Where.reset方法的典型用法代碼示例。如果您正苦於以下問題:Java Where.reset方法的具體用法?Java Where.reset怎麽用?Java Where.reset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.j256.ormlite.stmt.Where
的用法示例。
在下文中一共展示了Where.reset方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testUseOfAndMany
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void testUseOfAndMany() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
assertEquals(0, dao.countOf());
Foo foo1 = new Foo();
foo1.val = 1231231;
assertEquals(1, dao.create(foo1));
Foo foo2 = new Foo();
foo2.val = foo1.val + 1;
assertEquals(1, dao.create(foo2));
Where<Foo, Integer> where = dao.queryBuilder().where();
where.and(where.eq(Foo.VAL_COLUMN_NAME, foo1.val), where.eq(Foo.ID_COLUMN_NAME, foo1.id));
List<Foo> results = where.query();
assertEquals(1, results.size());
assertEquals(foo1.id, results.get(0).id);
// this should match none
where.reset();
where.and(where.eq(Foo.ID_COLUMN_NAME, foo1.id), where.eq(Foo.ID_COLUMN_NAME, foo2.id),
where.eq(Foo.VAL_COLUMN_NAME, foo1.val), where.eq(Foo.VAL_COLUMN_NAME, foo2.val));
results = where.query();
assertEquals(0, results.size());
}
示例2: testUseOfAndMany
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void testUseOfAndMany() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
assertEquals(0, dao.countOf());
Foo foo = new Foo();
int id = 1;
foo.id = id;
int val = 1231231;
foo.val = val;
assertEquals(1, dao.create(foo));
int notId = id + 1;
foo.id = notId;
foo.val = val + 1;
assertEquals(1, dao.create(foo));
Where<Foo, Integer> where = dao.queryBuilder().where();
where.and(where.eq(Foo.VAL_FIELD_NAME, val), where.eq(Foo.ID_FIELD_NAME, id));
List<Foo> results = where.query();
assertEquals(1, results.size());
assertEquals(id, results.get(0).id);
// this should match none
where.reset();
where.and(where.eq(Foo.VAL_FIELD_NAME, val), where.eq(Foo.ID_FIELD_NAME, id),
where.eq(Foo.ID_FIELD_NAME, notId));
results = where.query();
assertEquals(0, results.size());
}
示例3: testUseOfAndInt
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public void testUseOfAndInt() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
assertEquals(0, dao.countOf());
Foo foo = new Foo();
int id = 1;
foo.id = id;
int val = 1231231;
foo.val = val;
assertEquals(1, dao.create(foo));
int notId = id + 1;
foo.id = notId;
foo.val = val + 1;
assertEquals(1, dao.create(foo));
Where<Foo, Integer> where = dao.queryBuilder().where();
where.and(where.eq(Foo.VAL_FIELD_NAME, val), where.eq(Foo.ID_FIELD_NAME, id));
List<Foo> results = where.query();
assertEquals(1, results.size());
assertEquals(id, results.get(0).id);
// this should match none
where.reset();
where.eq(Foo.VAL_FIELD_NAME, val);
where.eq(Foo.ID_FIELD_NAME, id);
where.eq(Foo.ID_FIELD_NAME, notId);
where.and(3);
results = where.query();
assertEquals(0, results.size());
}
示例4: testQueryForUnicode
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public void testQueryForUnicode() throws Exception {
TableUtils.dropTable(connectionSource, Foo.class, true);
TableUtils.createTable(connectionSource, Foo.class);
try {
Dao<Foo, Object> dao = DaoManager.createDao(connectionSource, Foo.class);
Foo foo = new Foo();
String unicodeString = "上海";
foo.stuff = unicodeString;
assertEquals(1, dao.create(foo));
QueryBuilder<Foo, Object> qb = dao.queryBuilder();
Where<Foo, Object> where = qb.where();
where.eq(Foo.STUFF_FIELD_NAME, unicodeString);
List<Foo> results = qb.query();
assertNotNull(results);
assertEquals(1, results.size());
assertEquals(unicodeString, results.get(0).stuff);
where.reset();
where.eq(Foo.STUFF_FIELD_NAME, new SelectArg(unicodeString));
results = qb.query();
assertNotNull(results);
assertEquals(1, results.size());
assertEquals(unicodeString, results.get(0).stuff);
} finally {
TableUtils.dropTable(connectionSource, Foo.class, true);
}
}
示例5: testUseOfAndMany
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void testUseOfAndMany() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
assertEquals(0, dao.countOf());
Foo foo = new Foo();
int id = 1;
foo.id = id;
int val = 1231231;
foo.val = val;
assertEquals(1, dao.create(foo));
int notId = id + 1;
foo.id = notId;
foo.val = val + 1;
assertEquals(1, dao.create(foo));
Where<Foo, Integer> where = dao.queryBuilder().where();
where.and(where.eq(Foo.VAL_FIELD_NAME, val), where.eq(Foo.ID_FIELD_NAME, id));
List<Foo> results = where.query();
assertEquals(1, results.size());
assertEquals(id, results.get(0).id);
// this should match none
where.reset();
where.and(where.eq(Foo.VAL_FIELD_NAME, val), where.eq(Foo.ID_FIELD_NAME, id),
where.eq(Foo.ID_FIELD_NAME, notId));
results = where.query();
assertEquals(0, results.size());
}
示例6: testUseOfAndInt
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void testUseOfAndInt() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
assertEquals(0, dao.countOf());
Foo foo = new Foo();
int id = 1;
foo.id = id;
int val = 1231231;
foo.val = val;
assertEquals(1, dao.create(foo));
int notId = id + 1;
foo.id = notId;
foo.val = val + 1;
assertEquals(1, dao.create(foo));
Where<Foo, Integer> where = dao.queryBuilder().where();
where.and(where.eq(Foo.VAL_FIELD_NAME, val), where.eq(Foo.ID_FIELD_NAME, id));
List<Foo> results = where.query();
assertEquals(1, results.size());
assertEquals(id, results.get(0).id);
// this should match none
where.reset();
where.eq(Foo.VAL_FIELD_NAME, val);
where.eq(Foo.ID_FIELD_NAME, id);
where.eq(Foo.ID_FIELD_NAME, notId);
where.and(3);
results = where.query();
assertEquals(0, results.size());
}
示例7: testUseOfAndInt
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
@Test
public void testUseOfAndInt() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
assertEquals(0, dao.countOf());
Foo foo1 = new Foo();
foo1.val = 1231231;
assertEquals(1, dao.create(foo1));
Foo foo2 = new Foo();
foo2.val = foo1.val + 1;
assertEquals(1, dao.create(foo1));
Where<Foo, Integer> where = dao.queryBuilder().where();
where.eq(Foo.VAL_COLUMN_NAME, foo1.val);
where.eq(Foo.ID_COLUMN_NAME, foo1.id);
where.and(2);
List<Foo> results = where.query();
assertEquals(1, results.size());
assertEquals(foo1.id, results.get(0).id);
// this should match none
where.reset();
where.eq(Foo.ID_COLUMN_NAME, foo1.id);
where.eq(Foo.ID_COLUMN_NAME, foo2.id);
where.eq(Foo.VAL_COLUMN_NAME, foo1.val);
where.eq(Foo.VAL_COLUMN_NAME, foo2.val);
where.and(4);
results = where.query();
assertEquals(0, results.size());
}