本文整理匯總了Java中com.j256.ormlite.stmt.Where.query方法的典型用法代碼示例。如果您正苦於以下問題:Java Where.query方法的具體用法?Java Where.query怎麽用?Java Where.query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.j256.ormlite.stmt.Where
的用法示例。
在下文中一共展示了Where.query方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAgenda
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public List<ItemGridModel> getAgenda(){
try {
QueryBuilder<ItemGridModel, Integer> queryBuilder = getItemGridDao().queryBuilder();
Where<ItemGridModel, Integer> where = queryBuilder.where();
where.eq("isWatch", Boolean.TRUE);
where.and().ge("start", new Date(System.currentTimeMillis()));
queryBuilder.orderBy("start", true);
queryBuilder.orderBy("title", true);
List<ItemGridModel> items = where.query();
return items;
}
catch(SQLException e){
Log.e(Constant.TAG, "Error on fetch itens", e);
}
return null;
}
示例2: getItemGridByProposta
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public List<ItemGridModel> getItemGridByProposta(Integer pid){
try {
QueryBuilder<ItemGridModel, Integer> queryBuilder = getItemGridDao().queryBuilder();
Where<ItemGridModel, Integer> where = queryBuilder.where();
where.eq("pid", pid);
List<ItemGridModel> items = where.query();
return items;
}
catch(SQLException e){
Log.e(Constant.TAG, "Error on fetch item by pid: " + pid, e);
}
return null;
}
示例3: getHadithNoListForSection
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public List<Integer> getHadithNoListForSection(int sectionId) {
List<HadithMain> mainList = new ArrayList<>();
QueryBuilder<HadithMain, Integer> hadithMainQueryBuilder = getHelper().getHadithMainDao().queryBuilder();
Where<HadithMain, Integer> whereHadithMain = hadithMainQueryBuilder.where();
try {
whereHadithMain.eq("sectionId", sectionId);
mainList = whereHadithMain.query();
} catch (SQLException e) {
e.printStackTrace();
}
List<Integer> hadithIdList = new ArrayList<>();
for (HadithMain main : mainList) {
hadithIdList.add(main.getHadithNo());
}
return hadithIdList;
}
示例4: getContentTitleInfoForBook
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public List<BookContentTitleInfo> getContentTitleInfoForBook(int bookId) {
List<BookContent> contentList = new ArrayList<>();
List<BookContentTitleInfo> contentInfoList = new ArrayList<>();
QueryBuilder<BookContent, Integer> qb = getHelper().getBookContentDao().queryBuilder();
Where<BookContent, Integer> where = qb.where();
try {
where.eq("bookId", bookId);
contentList = where.query();
} catch (SQLException e) {
e.printStackTrace();
}
for (BookContent content : contentList) {
contentInfoList.add(new BookContentTitleInfo(content.getId(), content.getQuestion()));
}
return contentInfoList;
}
示例5: testUseOfOrMany
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void testUseOfOrMany() 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.or(where.eq(Foo.ID_FIELD_NAME, id), where.eq(Foo.ID_FIELD_NAME, notId),
where.eq(Foo.VAL_FIELD_NAME, val + 1), where.eq(Foo.VAL_FIELD_NAME, val + 1));
List<Foo> results = where.query();
assertEquals(2, results.size());
assertEquals(id, results.get(0).id);
assertEquals(notId, results.get(1).id);
}
示例6: loadInBackground
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
@Override
public List<BaseRecord> loadInBackground() {
try {
Dao<AnimeRecord, Integer> dao = getHelper().getDao(AnimeRecord.class);
Where<AnimeRecord, Integer> where = dao.queryBuilder().where().isNotNull("watched_status");
if ( filter != null ){
where.and().eq("watched_status", filter);
}
List<AnimeRecord> items = where.query();
Log.i(TAG, String.format("item count %d: filter: %s", items.size(), (filter != null) ? filter.getServerKey() : "NULL" ));
return new LinkedList<BaseRecord>(items);
} catch (SQLException e) {
Log.e(TAG, "", e);
}
return null;
}
示例7: findByFrom
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public List<PickupInfo> findByFrom(LocalDate d, boolean includeTaken) {
try {
Where<PickupInfo, Long> where = dao.queryBuilder().where();
where.eq(PickupInfo.COLUMN_FROM, d);
if (!includeTaken) {
where.and();
where.eq(PickupInfo.COLUMN_TAKEN, false);
}
return where.query();
} catch (SQLException e) {
throw new RuntimeException("Error finding model", e);
}
//return findBy(PickupInfo.COLUMN_FROM, d);
}
示例8: testUseOfOrMany
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public void testUseOfOrMany() 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.or(where.eq(Foo.ID_FIELD_NAME, id), where.eq(Foo.ID_FIELD_NAME, notId),
where.eq(Foo.VAL_FIELD_NAME, val + 1), where.eq(Foo.VAL_FIELD_NAME, val + 1));
List<Foo> results = where.query();
assertEquals(2, results.size());
assertEquals(id, results.get(0).id);
assertEquals(notId, results.get(1).id);
}
示例9: testUseOfOrInt
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public void testUseOfOrInt() 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.eq(Foo.ID_FIELD_NAME, id);
where.eq(Foo.ID_FIELD_NAME, notId);
where.eq(Foo.VAL_FIELD_NAME, val + 1);
where.eq(Foo.VAL_FIELD_NAME, val + 1);
where.or(4);
List<Foo> results = where.query();
assertEquals(2, results.size());
assertEquals(id, results.get(0).id);
assertEquals(notId, results.get(1).id);
}
示例10: 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());
}
示例11: testUseOfOrMany
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void testUseOfOrMany() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
assertEquals(0, dao.countOf());
Foo foo1 = new Foo();
int val = 1231231;
foo1.val = val;
assertEquals(1, dao.create(foo1));
Foo foo2 = new Foo();
foo2.val = val + 1;
assertEquals(1, dao.create(foo2));
Where<Foo, Integer> where = dao.queryBuilder().where();
where.or(where.eq(Foo.ID_COLUMN_NAME, foo1.id), where.eq(Foo.ID_COLUMN_NAME, foo2.id),
where.eq(Foo.VAL_COLUMN_NAME, val), where.eq(Foo.VAL_COLUMN_NAME, foo2.val));
List<Foo> results = where.query();
assertEquals(2, results.size());
assertEquals(foo1.id, results.get(0).id);
assertEquals(foo2.id, results.get(1).id);
}
示例12: testUseOfOrInt
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
@Test
public void testUseOfOrInt() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
assertEquals(0, dao.countOf());
Foo foo1 = new Foo();
int val = 1231231;
foo1.val = val;
assertEquals(1, dao.create(foo1));
Foo foo2 = new Foo();
foo2.val = val + 1;
assertEquals(1, dao.create(foo2));
Where<Foo, Integer> where = dao.queryBuilder().where();
where.eq(Foo.ID_COLUMN_NAME, foo1.id);
where.eq(Foo.ID_COLUMN_NAME, foo2.id);
where.eq(Foo.VAL_COLUMN_NAME, val);
where.eq(Foo.VAL_COLUMN_NAME, val + 1);
where.or(4);
List<Foo> results = where.query();
assertEquals(2, results.size());
assertEquals(foo1.id, results.get(0).id);
assertEquals(foo2.id, results.get(1).id);
}
示例13: updateItemGrid
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public void updateItemGrid(TimeModel time) {
try {
QueryBuilder<ItemGridModel, Integer> queryBuilder = getItemGridDao().queryBuilder();
Where<ItemGridModel, Integer> where = queryBuilder.where();
where.eq("time", time.getId());
List<ItemGridModel> results = where.query();
if(results != null) {
Map<Integer, Date> dayMap = new HashMap<>();
for (DayModel day : getDayDao().queryForAll()) {
dayMap.put(day.getId(), day.getDay());
}
for(ItemGridModel itemGrid : results) {
Integer timeId = itemGrid.getTime();
Integer dayId = itemGrid.getDate();
Calendar calendar = Calendar.getInstance();
calendar.setTime(dayMap.get(dayId));
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
itemGrid.setStart(Utils.getTime(calendar, timeId, true));
itemGrid.setEnd(Utils.getTime(calendar, timeId, false));
getItemGridDao().update(itemGrid);
}
}
}
catch(SQLException e){
Log.e(Constant.TAG, "Error on update time of itemgrid", e);
}
}
示例14: getItemsGrid
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public List<ItemGridModel> getItemsGrid(Integer date, Integer sessionType, Boolean isAgenda) {
try {
QueryBuilder<ItemGridModel, Integer> queryBuilder = getItemGridDao().queryBuilder();
Where<ItemGridModel, Integer> where = queryBuilder.where();
where.eq("date", date);
if (sessionType > 0) {
where.and().eq("type", sessionType);
}
if(isAgenda){
where.and().eq("isWatch", Boolean.TRUE);
}
queryBuilder.orderBy("start", true);
queryBuilder.orderBy("title", true);
List<ItemGridModel> items = where.query();
return items;
}
catch(SQLException e){
Log.e(Constant.TAG, "Error on fetch itens", e);
}
return null;
}
示例15: getHadithSectionsForBook
import com.j256.ormlite.stmt.Where; //導入方法依賴的package包/類
public List<HadithSection> getHadithSectionsForBook(int bookId) {
List<HadithSection> sectionList = new ArrayList<>();
QueryBuilder<HadithSection, Integer> qb = getHelper().getHadithSectionDao().queryBuilder();
Where<HadithSection, Integer> where = qb.where();
try {
where.eq("bookId", bookId);
sectionList = where.query();
} catch (SQLException e) {
e.printStackTrace();
}
return sectionList;
}