pdiffley
pdiffley

Reputation: 713

Can an ObjectBox property have multiple annotations?

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,
)

Upvotes: 0

Views: 116

Answers (1)

Markus Junginger
Markus Junginger

Reputation: 7075

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.

Upvotes: 1

Related Questions