Skip to main content

Like Start With methods

Definition

The Like Start With methods allow you to add the LIKE operator to the query. Additionally, the object or value that is received by parameter will be concatenated with the % character at the end.

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

Normal method nameShort method nameSQL to generate
likeStartWithlkswleftOp LIKE CONCAT(rightOp, '%')
notLikeStartWithnlkswNOT (leftOp LIKE CONCAT(rightOp, '%'))
info

For all cases, the object that calls Like Any 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. likeStartWith | lksw

SQL to generate
leftOperand LIKE CONCAT(rightOperand, '%')

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

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

Example: lksw(KColumn)

Java code:

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

SQL generated:

SELECT au.id
FROM app_user au
WHERE au.first_name LIKE CONCAT(au.last_name, '%')

Parameters:

  • None

Example: lksw(String)

Java code:

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

SQL generated:

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

Parameters:

  • ?1: "Jhon%"

Example: lksw(KOptionalString)

Java code:

final String nullValue = null;

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

SQL generated:

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

Parameters:

  • ?1: "Jhon%"

2. notLikeStartWith | nlksw

SQL to generate
NOT (leftOperand LIKE CONCAT(rightOperand, '%'))

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

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

Example: nlksw(KColumn)

Java code:

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

SQL generated:

SELECT au.id
FROM app_user au
WHERE NOT (au.first_name LIKE CONCAT(au.last_name, '%'))

Parameters:

  • None

Example: nlksw(String)

Java code:

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

SQL generated:

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

Parameters:

  • ?1: "Jhon%"

Example: nlksw(KOptionalString)

Java code:

final String nullValue = null;

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

SQL generated:

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

Parameters:

  • ?1: "Jhon%"