當前位置: 首頁>>代碼示例>>Java>>正文


Java QueryBuilder.countOf方法代碼示例

本文整理匯總了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;
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:21,代碼來源:CDKDao.java

示例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;
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:25,代碼來源:MyFavoritesBiz.java

示例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);
	}
}
 
開發者ID:phoenix-scholars,項目名稱:JPluf,代碼行數:28,代碼來源:PWikiBookDaoOrmlit.java

示例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);
	}
}
 
開發者ID:phoenix-scholars,項目名稱:JPluf,代碼行數:29,代碼來源:PWikiBookDaoOrmlit.java

示例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);
	}
}
 
開發者ID:phoenix-scholars,項目名稱:JPluf,代碼行數:28,代碼來源:PWikiPageDaoOrmLit.java


注:本文中的com.j256.ormlite.stmt.QueryBuilder.countOf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。