本文整理匯總了Java中de.greenrobot.dao.query.QueryBuilder.limit方法的典型用法代碼示例。如果您正苦於以下問題:Java QueryBuilder.limit方法的具體用法?Java QueryBuilder.limit怎麽用?Java QueryBuilder.limit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類de.greenrobot.dao.query.QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder.limit方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getMessagesForThreadForEntityID
import de.greenrobot.dao.query.QueryBuilder; //導入方法依賴的package包/類
/**
* Get all messages for given thread id ordered Ascending/Descending
*/
public List<BMessage> getMessagesForThreadForEntityID(Long id, int limit) {
List<BMessage> list ;
QueryBuilder<BMessage> qb = DaoCore.daoSession.queryBuilder(BMessage.class);
qb.where(BMessageDao.Properties.ThreadDaoId.eq(id));
// Making sure no null messages infected the sort.
qb.where(BMessageDao.Properties.Date.isNotNull());
qb.where(BMessageDao.Properties.Sender.isNotNull());
qb.orderDesc(BMessageDao.Properties.Date);
if (limit != -1)
qb.limit(limit);
list = qb.list();
return list;
}
示例2: fetchEntitiesWithPropertiesAndOrderAndLimit
import de.greenrobot.dao.query.QueryBuilder; //導入方法依賴的package包/類
public static <T extends Entity> List<T> fetchEntitiesWithPropertiesAndOrderAndLimit(Class<T> c, int limit, Property whereOrder, int order, Property properties[], Object... values){
if (values == null || properties == null)
throw new NullPointerException("You must have at least one value and one property");
if (values.length != properties.length)
throw new IllegalArgumentException("Values size should match properties size");
QueryBuilder<T> qb = daoSession.queryBuilder(c);
qb.where(properties[0].eq(values[0]));
if (values.length > 1)
for (int i = 0 ; i < values.length ; i++)
qb.where(properties[i].eq(values[i]));
if (whereOrder != null && order != -1)
switch (order)
{
case ORDER_ASC:
qb.orderAsc(whereOrder);
break;
case ORDER_DESC:
qb.orderDesc(whereOrder);
break;
}
if (limit != -1)
qb.limit(limit);
return qb.listLazy();
}
示例3: getMessagesWithOrder
import de.greenrobot.dao.query.QueryBuilder; //導入方法依賴的package包/類
/** Fetch messages list from the db for current thread, Messages will be order Desc/Asc on demand.*/
public List<BMessage> getMessagesWithOrder(int order, int limit){
List<BMessage> list ;/*= DaoCore.fetchEntitiesWithProperty(BMessage.class, BMessageDao.Properties.OwnerThread, getId());*/
QueryBuilder<BMessage> qb = daoSession.queryBuilder(BMessage.class);
qb.where(BMessageDao.Properties.ThreadDaoId.eq(getId()));
// Making sure no null messages infected the sort.
qb.where(BMessageDao.Properties.Date.isNotNull());
if (limit != -1)
qb.limit(limit);
list = qb.list();
Collections.sort(list, new MessageSorter(order));
return list;
}