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

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -