All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.itranswarp.warpdb.From Maven / Gradle / Ivy

There is a newer version: 6.0.3
Show newest version
package com.itranswarp.warpdb;

import java.util.List;

import com.itranswarp.warpdb.entity.BaseEntity;

public final class From {

	final SelectInfo info;

	From(Database database, Class clazz) {
		this.info = new SelectInfo(database, clazz);
	}

	public Where where(String clause, Object... args) {
		return new Where(this.info, clause, args);
	}

	public OrderBy orderBy(String orderBy) {
		return new OrderBy(this.info, orderBy);
	}

	/**
	 * Get all results as list.
	 * 
	 * @return list.
	 */
	public List list() {
		return info.list();
	}

	/**
	 * Do page query using default items per page.
	 * 
	 * @param pageIndex
	 * @return pageResult
	 */
	public PagedResults list(int pageIndex) {
		return info.list(pageIndex, Page.DEFAULT_ITEMS_PER_PAGE);
	}

	/**
	 * Do page query.
	 * 
	 * @param pageIndex
	 * @param itemsPerPage
	 * @return
	 */
	public PagedResults list(int pageIndex, int itemsPerPage) {
		return info.list(pageIndex, itemsPerPage);
	}

	/**
	 * Get count as int.
	 * 
	 * @return int count
	 */
	public int count() {
		return info.count();
	}

	/**
	 * Get first row of the query, or null if no result found.
	 */
	public T first() {
		return info.first();
	}

	/**
	 * Get unique result of the query. Exception will throw if no result found
	 * or more than 1 results found.
	 * 
	 * @return T modelInstance
	 */
	public T unique() {
		return info.unique();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy