dup key on @CompoundIndexes

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.2.2
    • Component/s: None
    • None
    • Environment:
      java 8, mongo Spring data,
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I have created pojo class and use this annotation:-

      @CompoundIndexes(value = { @CompoundIndex(name = "Metadata _ind1", def = "

      {'index': 1, 'projectId': 1}

      ", unique = true) })
      @Document(collection = "metadata")
      public class MetadataCommBean

      { -- variables-- -- getter/ setter-- }

      and after sum updation on my list of documents i am saving my updates in collection by using mononRepository.save(updatedList)
      and this statement throws error:-

      com.mongodb.MongoException$DuplicateKey: { "serverUsed" : "localhost:27017" , "ok" : 1 , "n" : 0 , "updatedExisting" : false ,
      "err" : "E11000 duplicate key error collection: metadata_db.metadata index: Metadata _ind1 dup key: { : \"1.1.2\", : \"11\" }" , "code" : 11000}

      how can i solve this

            Assignee:
            Unassigned
            Reporter:
            sorabh sahu
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: