Limit
Definition
The limit method allows you to add the LIMIT clause to the query.
Available methods
1. limit(int count)
- count: an int value which will be added to
LIMITclause.
2. limit(long count)
- count: a long value which will be added to
LIMITclause.
3. limit(KOptionalLong kOptionalLong)
- kOptionalLong: a long value which will be added to
LIMITclause.
Method hierarchy
The limit method can be used right after the following methods:
selectDistinct,select1,select,from,innerJoin,leftJoin,rightJoin,fullJoin,crossJoin,where,and,andNot,or,orNot,groupBy,having,and,andNot,or,orNot,window,except,exceptAll,intersect,intersectAll,union,unionAll,orderBy
and the subsequent methods that can be called are:
Example: int
Java code:
k
.select(
APP_USER.FIRST_NAME
)
.from(APP_USER)
.limit(10)
.multiple();
SQL generated:
SELECT au.first_name
FROM app_user au
LIMIT 10
Parameters:
- None
Example: KOptionalLong (null value)
Java code:
final Long nullLong = null;
k
.select(
APP_USER.FIRST_NAME
)
.from(APP_USER)
.limit(optional(nullLong))
.multiple();
SQL generated:
SELECT au.first_name
FROM app_user au
Parameters:
- None
Example: KOptionalLong (not null value)
Java code:
final Long nullLong = 10;
k
.select(
APP_USER.FIRST_NAME
)
.from(APP_USER)
.limit(optional(nullLong))
.multiple();
SQL generated:
SELECT au.first_name
FROM app_user au
LIMIT 10
Parameters:
- None