Package st.orm

Interface Metamodel.Key<T extends Data,E>

Type Parameters:
T - the root table type.
E - the field type of the designated element.
All Superinterfaces:
Metamodel<T,E>
All Known Implementing Classes:
AbstractKeyMetamodel, Metamodel.KeyDelegate
Enclosing interface:
Metamodel<T extends Data,E>

public static interface Metamodel.Key<T extends Data,E> extends Metamodel<T,E>
Marker interface for metamodel fields that correspond to columns known to be unique. Metamodel fields generated for @UK or @PK record components implement this interface automatically.

Key instances can be used where a unique column is required, such as keyset pagination cursors and single-result lookups via repository methods like findBy and getBy.

A Key can also be created manually via the Metamodel.key(Metamodel) factory method for columns that are known to produce unique values in a specific query context (for example, a column used in a GROUP BY clause). In such cases, the caller is responsible for ensuring that the values are unique within the result set; using a non-unique column as a keyset pagination key silently skips rows when duplicates span page boundaries.

Since:
1.9
See Also:
  • Method Details

    • isNullable

      boolean isNullable()
      Returns true if this key field allows NULL values with standard SQL distinct-NULL semantics, meaning the UNIQUE constraint does not prevent multiple NULLs.

      A nullable key is unsafe for keyset pagination because WHERE key > cursor silently excludes NULL rows. The scroll methods check this flag and throw a PersistenceException if the key is nullable.

      Returns:
      true if this key allows duplicate NULLs (nullable with nullsDistinct = true), false otherwise.
      Since:
      1.9
      See Also: