Annotation Type Unique


  • @Retention(CLASS)
    @Target(FIELD)
    public @interface Unique
    Enforces that the value of a property is unique among all objects in a box before an object can be put.

    Trying to put an object with offending values will result in a UniqueViolationException (see ConflictStrategy.FAIL). Set onConflict() to change this strategy.

    Note: Unique properties are based on an @Index, so the same restrictions apply. It is supported to explicitly add the @Index annotation to configure the index.

    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      ConflictStrategy onConflict
      The strategy to use when a conflict is detected when an object is put.
    • Element Detail

      • onConflict

        ConflictStrategy onConflict
        The strategy to use when a conflict is detected when an object is put.
        Default:
        io.objectbox.annotation.ConflictStrategy.FAIL