com.itranswarp.warpdb.From Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of warpdb Show documentation
Show all versions of warpdb Show documentation
Simple, DSL-driven RDBMS interface for Java
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();
}
}