spring - Mongo @DBRef unique -
my application uses spring boot / jpa / mongodb.
i map domain classes mongodb using
org.springframework.data.mongodb.core.mapping.document; org.springframework.data.mongodb.core.index.indexed; org.springframework.data.mongodb.core.mapping.dbref;
all except when trying make dbref unique :
@dbref @indexed(unique = true) private user owner;
i have tried different combinations of @dbref, @indexed (unique=true) , cannot make dbref unique. can make other field-types unique, such 'name' in following example
@indexed(unique = true) @size(min = 2, max = 100) @column(length = 100) private string name;
but cannot find how make dbref field unique.
i'm coming morphia side of mapping, i'd try this:
@compoundindexes({ @compoundindex(name = "owner", def = "{'owner.id' : 1}", unique = true) })
Comments
Post a Comment