本文整理汇总了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);
}
}