本文整理匯總了Java中com.j256.ormlite.stmt.QueryBuilder.countOf方法的典型用法代碼示例。如果您正苦於以下問題:Java QueryBuilder.countOf方法的具體用法?Java QueryBuilder.countOf怎麽用?Java QueryBuilder.countOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.j256.ormlite.stmt.QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder.countOf方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getCount
import com.j256.ormlite.stmt.QueryBuilder; //導入方法依賴的package包/類
/**
* 返回記錄總數
*
* @return
*/
public long getCount()
{
QueryBuilder<Model, ?> queryBuilder = mRuntimeDao.queryBuilder();
try
{
return queryBuilder.countOf();
}
catch (SQLException e)
{
e.printStackTrace();
}
return 0;
}
示例2: exists
import com.j256.ormlite.stmt.QueryBuilder; //導入方法依賴的package包/類
/**
* 是否存在
*
* @param largeUrl
* @return
*/
public boolean exists(String largeUrl)
{
try
{
QueryBuilder<MyFavorites, Long> queryBuilder = mMyFavoritesDao.queryBuilder();
// queryBuilder.where().eq("largeUrl", largeUrl);
// 加密判斷是否存在
queryBuilder.where().eq("largeUrl", SecurityTu123.encodeImageUrl(largeUrl));
return queryBuilder.countOf() > 0 ? true : false;
}
catch (SQLException e)
{
e.printStackTrace();
}
return false;
}
示例3: findWikiBook
import com.j256.ormlite.stmt.QueryBuilder; //導入方法依賴的package包/類
@Override
public IPPaginatorPage<PWikiBook> findWikiBook(PPaginatorParameter param) {
QueryBuilder<PWikiBook, Long> queryBuilder = wikiDao.queryBuilder();
try {
// count
Long count = queryBuilder.countOf();
// Items
queryBuilder = wikiDao.queryBuilder();
queryBuilder//
.limit((long) param.getItemPerPage())//
.offset((long) param.getPage() * param.getItemPerPage());
PreparedQuery<PWikiBook> preparedQuery = queryBuilder.prepare();
List<PWikiBook> list = wikiDao.query(preparedQuery);
PPaginatedWikiBook page = new PPaginatedWikiBook();
page//
.setItems(list)//
.setItemsPerPage(param.getItemPerPage())//
.setCurrentPage(param.getPage())//
.setPageNumber(count.intValue() / param.getItemPerPage()
+ ((count.intValue() % param.getItemPerPage() != 0) ? 1 : 0));
return page;
} catch (SQLException e) {
throw new PException(e.getMessage(), e);
}
}
示例4: getBookPages
import com.j256.ormlite.stmt.QueryBuilder; //導入方法依賴的package包/類
@Override
public IPPaginatorPage<PWikiPageItem> getBookPages(PWikiBook book, PPaginatorParameter param) {
try {
// count
QueryBuilder<PWikiPage, Long> queryBuilder = wikiPageDao.queryBuilder();
queryBuilder.where().eq("book", book.getId());
Long count = queryBuilder.countOf();
// Items
queryBuilder = wikiPageDao.queryBuilder();
queryBuilder//
.limit((long) param.getItemPerPage())//
.offset((long) param.getPage() * param.getItemPerPage()).where().eq("book", book.getId());
PreparedQuery<PWikiPage> preparedQuery = queryBuilder.prepare();
List<PWikiPage> list = wikiPageDao.query(preparedQuery);
PPaginatedWikiItemPage page = new PPaginatedWikiItemPage();
page//
.setItems(list)//
.setItemsPerPage(param.getItemPerPage())//
.setCurrentPage(param.getPage())//
.setPageNumber(count.intValue() / param.getItemPerPage()
+ ((count.intValue() % param.getItemPerPage() != 0) ? 1 : 0));
return page;
} catch (Exception e) {
throw new PException(e.getMessage(), e);
}
}
示例5: findWikiPage
import com.j256.ormlite.stmt.QueryBuilder; //導入方法依賴的package包/類
@Override
public IPPaginatorPage<PWikiPage> findWikiPage(PPaginatorParameter param) {
try {
// count
QueryBuilder<PWikiPage, Long> queryBuilder = wikiPageDao.queryBuilder();
Long count = queryBuilder.countOf();
// Items
queryBuilder = wikiPageDao.queryBuilder();
queryBuilder//
.limit((long) param.getItemPerPage())//
.offset((long) param.getPage() * param.getItemPerPage());
PreparedQuery<PWikiPage> preparedQuery = queryBuilder.prepare();
List<PWikiPage> list = wikiPageDao.query(preparedQuery);
PPaginatedWikiPage page = new PPaginatedWikiPage();
page//
.setItems(list)//
.setItemsPerPage(param.getItemPerPage())//
.setCurrentPage(param.getPage())//
.setPageNumber(count.intValue() / param.getItemPerPage()
+ ((count.intValue() % param.getItemPerPage() != 0) ? 1 : 0));
return page;
} catch (SQLException e) {
throw new PException(e.getMessage(), e);
}
}