Skip to main content

Like methods

Definition

The Like methods allow you to add the LIKE operator to the query.

The methods available in Normal method name and the Short method name versions are:

Normal method nameShort method nameSQL to generate
likelkleftOp LIKE rightOp
notLikenlkNOT (leftOp LIKE rightOp)
info

For all cases, the object that calls Like methods will be placed as the operand on the left side of the LIKE operator and the object or value received by parameter will be placed on the right side of the LIKE operator.

1. like | lk

SQL to generate
leftOperand LIKE rightOperand

This method takes a single parameter and the possible values are:

KTableColumn, KColumn, String, KValTextField, KOptionalKColumn, KOptionalString, KOptionalKValTextField.

Example: lk(KColumn)

Java code:

k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.FIRST_NAME.lk(APP_USER.LAST_NAME))
.multiple();

SQL generated:

SELECT au.id
FROM app_user au
WHERE au.first_name LIKE au.last_name

Parameters:

  • None

Example: lk(String)

Java code:

k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.FIRST_NAME.lk("Jhon"))
.multiple();

SQL generated:

SELECT au.id
FROM app_user au
WHERE au.first_name LIKE ?1

Parameters:

  • ?1: "Jhon"

Example: lk(KOptionalString)

Java code:

final String nullValue = null;

k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.FIRST_NAME.lk(optional(nullValue)))
.and(APP_USER.FIRST_NAME.lk(optional("Jhon")))
.multiple();

SQL generated:

SELECT au.id
FROM app_user au
WHERE au.first_name LIKE ?1

Parameters:

  • ?1: "Jhon"

2. notLike | nlk

SQL to generate
NOT (leftOperand LIKE rightOperand)

This method takes a single parameter and the possible values are:

KTableColumn, KColumn, String, KValTextField, KOptionalKColumn, KOptionalString, KOptionalKValTextField.

Example: nlk(KColumn)

Java code:

k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.FIRST_NAME.nlk(APP_USER.LAST_NAME))
.multiple();

SQL generated:

SELECT au.id
FROM app_user au
WHERE NOT (au.first_name LIKE au.last_name)

Parameters:

  • None

Example: nlk(String)

Java code:

k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.FIRST_NAME.nlk("Jhon"))
.multiple();

SQL generated:

SELECT au.id
FROM app_user au
WHERE NOT (au.first_name LIKE ?1)

Parameters:

  • ?1: "Jhon"

Example: nlk(KOptionalString)

Java code:

final String nullValue = null;

k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.FIRST_NAME.nlk(optional(nullValue)))
.and(APP_USER.FIRST_NAME.nlk(optional("Jhon")))
.multiple();

SQL generated:

SELECT au.id
FROM app_user au
WHERE NOT (au.first_name LIKE ?1)

Parameters:

  • ?1: "Jhon"