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

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

    Hello,

    I am working with a data source from the US deparment of education ( http://ope.ed.gov/accreditation/). 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).

    Consider

    Code:
    @Document(collection="institutions")
    public class AccreditedPostsecondaryInstitution extends Places {
    	@SuppressWarnings("unused")
    	@Id
    	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?

    -jk
Working...
X