elementAtOrElse

inline fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.elementAtOrElse(index: Int, defaultValue: (Int) -> E): E(source)

Return an element at the given index or the result of calling the defaultValue function if the index is out of bounds of this sequence.

Especially, if a dialect is enabled, this function will use the pagination feature to obtain the very record only. Assuming we are using MySQL and calling this function with an index 10, a SQL containing limit 10, 1 will be generated. But if there are no dialects enabled, then all records in the sequence will be obtained to ensure the function just works.

The operation is terminal.