spring data - Springdata MongoDB automatically generates and undesired unique index in subdocuments -



spring data - Springdata MongoDB automatically generates and undesired unique index in subdocuments -

i , storing doc objects in mongodb repository ensuring barcode property unique across collection:

@document(collection = "doc") public class doc { @id private string id; @indexed(unique = true) private string barcode; ... }

i store docaudit collection stores lists of doc sub-documents:

@document(collection = "docaudit") public class docaudit { @id private string id; private list<doc> docs; ... }

as docaudit entries generated, same doc can nowadays in docs list of 2 or more docaudit entries.

the @indexed(unique = true) on barcode property of doc object automatically generating mongodb indexes on doc.barcode (desired) , docaudit.docs.doc.barcode (undesired)

what's best way avoid automatic generation of undesired index? alternatively, what's best way remove undesired index created?

docaudit of course of study having these properties of doc, because docaudit inheritor. accomplish want, may consider 1 of following:

create doc without annotation, inherited docaudit; remove annotation in doc, , ensure index doc independent codes (not recommended);

it's not create index , drop immediately.

mongodb spring-data spring-data-mongodb

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -