Announcement Announcement Module
No announcement yet.
What should an insert do if the @Id isn't unique? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • What should an insert do if the @Id isn't unique?


    I am working with a data source from the US deparment of education ( There are just over 26 thousand rows in the csv file. My code happily inserts java objects into my mongo repository. Unfortunately, it silently disgards about 2/3 of them. For example, if I insert the first 10 rows from the csv into Mongo, only 3 are recorded. Why?

    Is there some error(code/exception/log) I am ignoring on inserts which do not work? Things I thought to check.
    1. Added a try block with a catch block for both DataAccessException and Exception. No exception thrown.
    2. I see no error messages in the mongo.log file
    3. MongoTemplate.insert() returns void (ie, no error code).


    public class AccreditedPostsecondaryInstitution extends Places {
    	private String instituteId;
    Turns out the instituteId which I thought was unique for each row isn't unique. What is suppose to happen in this case? It appears to silently ignore inserts where the @Id already exists. Is that right? Is there a way to make this collision explicit during debugging?