Duplicates are being created in MongoDB

26 views
Skip to first unread message

jayasree.ja...@gmail.com

unread,
Apr 5, 2018, 1:55:55 PM4/5/18
to mongodb-dev
Hi,
I have created a DAO class where I'm using @CompoundIndexes to avoid duplicates into my DB but still the entries are being populated. Any idea about how we can avoid it?

Example class:
@Document(collection = "ABC")
@CompoundIndexes({
        @CompoundIndex(def = "{'A.B.x':1, 'A.B.y':1}", name = "compound_index_1"),
@CompoundIndex(def = "{'A.C.k':1, 'A.C.l':1}", name = "compound_index_2")
})
public class XXX{
private A a;
private String dateOfEntry;
private String dateOfUpdate;
}

class A {
private B b;
private C c;
private string status;

}

class B {
private string x;
private string y;
}

class C{
private string k;
private string l;
private string m;
}

Wan Bachtiar

unread,
Jun 13, 2018, 2:21:36 AM6/13/18
to mongodb-dev

Hi,

Note that questions related to the use of MongoDB (i.e. your question) are better sent to mongodb-user group. This group (mongodb-dev) is for discussion for/by/about developers/development/code of MongoDB.

Please see MongoDB: Unique Indexes for information preventing duplicates entry based on unique field(s). 

If you have further questions about duplicates, please post a new discussion on mongodb-user group along with information below:

  • MongoDB version.
  • Example of MongoDB documents.
  • Steps to reproduce the problem. 

Regards,

Wan.

Reply all
Reply to author
Forward
0 new messages