Announcement Announcement Module
Collapse
No announcement yet.
Spring Data Mongo not reporting mongo unique constraint error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Data Mongo not reporting mongo unique constraint error

    Hi

    I am new to using Spring Data with mongo. I configured mongo to have unique contraint on a collection so that the name element is unique.

    The code works as expected, not allowing duplicates to be entered, but I get nothing back in the app - no exception or error.

    How can I set this to occur?

    Thanks for your help....

  • #2
    a little more clarification....if a user enter a name that is already in mongo I want to be notified some how so I can display the message to the user in the UI

    Comment


    • #3
      At the risk of talking to myself, I found the answer to my own question. It's amazing what happens when one reads the instructions

      I added this statement when creating my mongotemplate and I am good to go. Exceptions are now thrown and caught.

      mongoTemplate.setWriteConcern(WriteConcern.SAFE);

      Comment

      Working...
      X