Equal methods
Definition
The Equal methods allow you to add the = operator to the query.
The methods available in Normal method name and the Short method name versions are:
Normal method name | Short method name | SQL to generate |
---|---|---|
equal | eq | leftOp = rightOp |
iEqual | ieq | LOWER(leftOp) = LOWER(rightOp) |
notEqual | neq | NOT (leftOp = rightOp) |
notIEqual | nieq | NOT (LOWER(leftOp) = LOWER(rightOp)) |
For all cases, the object that calls Equal methods will be placed as the operand on the left side of the = operator and the object or value received by parameter will be placed on the right side of the = operator.
1. equal | eq
leftOperand = rightOperand
This method takes a single parameter and the possible values are:
KTableColumn
, KColumn
, Number
, String
, LocalDate
, LocalDateTime
, UUID
, KValNumberField
, KValTextField
, KQuery
, KOptionalKColumn
, KOptionalNumber
, KOptionalString
, KOptionalLocalDate
, KOptionalLocalDateTime
, KOptionalUuid
, KOptionalKValNumberField
, KOptionalKValTextField
, KOptionalLong
.
If the object received by parameter is a KQuery
, it will be treated as a subquery and you must ensure that it returns only one column comparable to the operand on the left side of the condition.
Example: eq(KColumn)
Java code:
k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.FIRST_NAME.eq(APP_USER.LAST_NAME))
.multiple();
SQL generated:
SELECT au.id
FROM app_user au
WHERE au.first_name = au.last_name
Parameters:
- None
Example: eq(String)
Java code:
k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.FIRST_NAME.eq("Jhon"))
.multiple();
SQL generated:
SELECT au.id
FROM app_user au
WHERE au.first_name = ?1
Parameters:
- ?1: "Jhon"
Example: eq(KOptionalString)
Java code:
final String nullValue = null;
k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.FIRST_NAME.eq(optional(nullValue)))
.and(APP_USER.FIRST_NAME.eq(optional("Jhon")))
.multiple();
SQL generated:
SELECT au.id
FROM app_user au
WHERE au.first_name = ?1
Parameters:
- ?1: "Jhon"
Example: eq(KQuery)
Java code:
final KQuery subquery =
k
.select(max(APP_USER_SPECIALTY.APP_USER_ID))
.from(APP_USER_SPECIALTY);
k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.ID.eq(subquery))
.multiple();
SQL generated:
SELECT au.id
FROM app_user au
WHERE au.id = (
SELECT MAX(aus.app_user_id)
FROM app_user_specialty aus
)
Parameters:
- None
Example: eq(KTuple
)
Java code:
k
.select(APP_USER.ID)
.from(APP_USER)
.where(
tuple(APP_USER.FIRST_NAME, APP_USER.EMAIL)
.eq(
tuple(val("kecon"), val("contacto@myzlab.com"))
)
)
.multiple();
SQL generated:
SELECT au.id
FROM auth.app_user au
WHERE (au.first_name, au.email) = (?1, ?2)
Parameters:
- ?1: "kecon"
- ?2: "contacto@myzlab.com"
2. iEqual | ieq
LOWER(leftOperand) = LOWER(rightOperand)
This method takes a single parameter and the possible values are:
KTableColumn
, KColumn
, String
, KValTextField
, KOptionalKColumn
, KOptionalString
, KOptionalKValTextField
.
Example: ieq(KColumn)
Java code:
k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.FIRST_NAME.ieq(APP_USER.LAST_NAME))
.multiple();
SQL generated:
SELECT au.id
FROM app_user au
WHERE LOWER(au.first_name) = LOWER(au.last_name)
Parameters:
- None
Example: ieq(String)
Java code:
k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.FIRST_NAME.ieq("Jhon"))
.multiple();
SQL generated:
SELECT au.id
FROM app_user au
WHERE LOWER(au.first_name) = ?1
Parameters:
- ?1: "jhon"
Example: ieq(KOptionalString)
Java code:
final String nullValue = null;
k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.FIRST_NAME.ieq(optional(nullValue)))
.and(APP_USER.FIRST_NAME.ieq(optional("Jhon")))
.multiple();
SQL generated:
SELECT au.id
FROM app_user au
WHERE LOWER(au.first_name) = ?1
Parameters:
- ?1: "jhon"
3. notEqual | neq
NOT (leftOperand = rightOperand)
This method takes a single parameter and the possible values are:
KTableColumn
, KColumn
, Number
, String
, LocalDate
, LocalDateTime
, UUID
, KValNumberField
, KValTextField
, KQuery
, KOptionalKColumn
, KOptionalNumber
, KOptionalString
, KOptionalLocalDate
, KOptionalLocalDateTime
, KOptionalUuid
, KOptionalKValNumberField
, KOptionalKValTextField
, KOptionalLong
.
If the object received by parameter is a KQuery
, it will be treated as a subquery and you must ensure that it returns only one column comparable to the operand on the left side of the condition.
Example: neq(KColumn)
Java code:
k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.FIRST_NAME.neq(APP_USER.LAST_NAME))
.multiple();
SQL generated:
SELECT au.id
FROM app_user au
WHERE NOT (au.first_name = au.last_name)
Parameters:
- None
Example: neq(String)
Java code:
k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.FIRST_NAME.neq("Jhon"))
.multiple();
SQL generated:
SELECT au.id
FROM app_user au
WHERE NOT (au.first_name = ?1)
Parameters:
- ?1: "Jhon"
Example: neq(KOptionalString)
Java code:
final String nullValue = null;
k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.FIRST_NAME.neq(optional(nullValue)))
.and(APP_USER.FIRST_NAME.neq(optional("Jhon")))
.multiple();
SQL generated:
SELECT au.id
FROM app_user au
WHERE NOT (au.first_name = ?1)
Parameters:
- ?1: "Jhon"
Example: neq(KQuery)
Java code:
final KQuery subquery =
k
.select(max(APP_USER_SPECIALTY.APP_USER_ID))
.from(APP_USER_SPECIALTY);
k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.ID.neq(subquery))
.multiple();
SQL generated:
SELECT au.id
FROM app_user au
WHERE NOT (
au.id = (
SELECT MAX(aus.app_user_id)
FROM app_user_specialty aus
)
)
Parameters:
- None
Example: neq(KColumn (tuple))
Java code:
k
.select(APP_USER.ID)
.from(APP_USER)
.where(
tuple(APP_USER.FIRST_NAME, APP_USER.EMAIL)
.neq(
tuple(val("kecon"), val("contacto@myzlab.com"))
)
)
.multiple();
SQL generated:
SELECT au.id
FROM auth.app_user au
WHERE NOT ((au.first_name, au.email) = (?1, ?2))
Parameters:
- ?1: "kecon"
- ?2: "contacto@myzlab.com"
4. notIEqual | nieq
NOT (LOWER(leftOperand) = LOWER(rightOperand))
This method takes a single parameter and the possible values are:
KTableColumn
, KColumn
, String
, KValTextField
, KOptionalKColumn
, KOptionalString
, KOptionalKValTextField
.
Example: nieq(KColumn)
Java code:
k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.FIRST_NAME.nieq(APP_USER.LAST_NAME))
.multiple();
SQL generated:
SELECT au.id
FROM app_user au
WHERE NOT (LOWER(au.first_name) = LOWER(au.last_name))
Parameters:
- None
Example: nieq(String)
Java code:
k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.FIRST_NAME.nieq("Jhon"))
.multiple();
SQL generated:
SELECT au.id
FROM app_user au
WHERE NOT (LOWER(au.first_name) = ?1)
Parameters:
- ?1: "jhon"
Example: nieq(KOptionalString)
Java code:
final String nullValue = null;
k
.select(APP_USER.ID)
.from(APP_USER)
.where(APP_USER.FIRST_NAME.nieq(optional(nullValue)))
.and(APP_USER.FIRST_NAME.nieq(optional("Jhon")))
.multiple();
SQL generated:
SELECT au.id
FROM app_user au
WHERE NOT (LOWER(au.first_name) = ?1)
Parameters:
- ?1: "jhon"