Can an ObjectBox property have multiple annotations?

125 Views Asked by At

ObjectBox documents several annotations that can be applied to and entity's properties. Can one property have multiple annotations?

For example, would this be a valid entity?

@Entity
data class User(
    @Id 
    var id: Long = 0,
    @Index 
    @Unique(onConflict = ConflictStrategy.REPLACE)
    var name: String = null,
)
1

There are 1 best solutions below

0
On BEST ANSWER

Yes, a property (and and entity) can have multiple annotations.

Your example with @Index and @Unique is valid; however, because @Unique implies @Index, the latter is redundant and can be removed.