Package st.orm

Annotation Interface Persist


@Target({RECORD_COMPONENT,PARAMETER}) @Retention(RUNTIME) public @interface Persist
Allows the persistence properties of a record component to be configured.

This annotation is only relevant in case the record is going to be persisted using an INSERT or UPDATE statement.

When placed on an inline record field, the annotation is propagated to all child fields of the inline record. Child fields can override the inherited annotation with their own @Persist.

Java:


 record UserRole(@PK UserRolePk pk,
                 @FK @Persist(insertable = false, updatable = false) User user,
                 @FK @Persist(insertable = false, updatable = false) Role role
 ) implements Entity<UserRolePk> {}
 

Kotlin:


 data class UserRole(@PK val pk: UserRolePk,
                     @FK @Persist(insertable = false, updatable = false) val user: User,
                     @FK @Persist(insertable = false, updatable = false) val role: Role
 ) : Entity<UserRolePk>
 
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Whether the component will be inserted when the record is persisted.
    boolean
    Whether the component will be updated when the record is persisted.
  • Element Details

    • insertable

      boolean insertable
      Whether the component will be inserted when the record is persisted.
      Returns:
      true if the component will be inserted, false otherwise.
      Default:
      true
    • updatable

      boolean updatable
      Whether the component will be updated when the record is persisted.
      Returns:
      true if the component will be updated, false otherwise.
      Default:
      true