Results 1 to 3 of 3

Thread: Spring Data Mongo not reporting mongo unique constraint error

  1. #1
    Join Date
    Nov 2012
    Posts
    3

    Default 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. #2
    Join Date
    Nov 2012
    Posts
    3

    Default

    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

  3. #3
    Join Date
    Nov 2012
    Posts
    3

    Default

    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);

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •