Skip to main content

Find One By

Definition

The findOneBy method allows you to get one record of a table filtered by the conditions that are supplied.

caution

If the constructed query returns 0 or more than one record, this method will return a null KRow.

Available methods

Example: KFindFunction, KColumnAllowedToSelect...

Java code:

final Language language =
languageRepository.findOneBy(
(KFrom kFrom) ->
kFrom
.where(LANGUAGE.ID.eq(7L)),
LANGUAGE.ID,
LANGUAGE.NAME
);

SQL generated:

SELECT la.id, la.name
FROM language la
WHERE la.id = ?1

Parameters:

  • ?1: 7

Example: String, KFindFunction, KColumnAllowedToSelect...

Java code:

final Language language =
languageRepository.findOneBy(
K.JDBC_LEGACY,
(KFrom kFrom) ->
kFrom
.where(LANGUAGE.ID.eq(7L)),
LANGUAGE.ID,
LANGUAGE.NAME
);

SQL generated:

SELECT la.id, la.name
FROM language la
WHERE la.id = ?1

Parameters:

  • ?1: 7