Annotation Interface Upsert


@Documented @Retention(RUNTIME) @Target(METHOD) public @interface Upsert

Lifecycle annotation for repository methods which perform upsert operations.

The Upsert annotation indicates that the annotated repository method adds the state of one or more entities to the database when missing, or updates the existing database state when present.

An Upsert method accepts an instance or instances of an entity class. The method must have exactly one parameter whose type is either:

  • the class of the entity to be upserted, or
  • Iterable<E> where E is the class of the entities to be upserted.

The annotated method may be declared void, return a number type, return the entity type, or return an iterable/reactive/asynchronous container producing the entity type, depending on the repository type.

By default, the entity identity is used to determine whether an existing row should be updated. The conflictsOn() member can be used to select a different property or set of properties as the conflict target.

Since:
5.2.0
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The persistent entity properties to use as the conflict target.
  • Element Details

    • conflictsOn

      String[] conflictsOn
      The persistent entity properties to use as the conflict target.
      Returns:
      The conflict target properties
      Default:
      {}