Skip to main content

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 LIMIT clause.

2. limit(long count)

  • count: a long value which will be added to LIMIT clause.

3. limit(KOptionalLong kOptionalLong)

  • kOptionalLong: a long value which will be added to LIMIT clause.

Method hierarchy

The limit method can be used right after the following methods:

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