I'm using Spring Mongo 1.0.0M2. I tried to update a property in a document and it failed when query by ID. This is the mongo template configuration:
The injected MongoOperations works for save document, update entire document. It also works fine when:Code:@Override public Mongo mongo() throws Exception { ServerAddress address = new ServerAddress( "127.0.0.1" , 27017); MongoOptions options = new MongoOptions(); options.autoConnectRetry = true; options.connectionsPerHost=10; options.threadsAllowedToBlockForConnectionMultiplier=5; options.maxWaitTime=6000; options.connectTimeout=0; options.socketTimeout=0; Mongo mongo = new Mongo(address, options); return mongo; } @Override public MongoTemplate mongoTemplate() throws Exception { MongoTemplate mongoTemplate = new MongoTemplate(mongo(), "ecl"); mongoTemplate.setMongoConverter(mappingMongoConverter()); mongoTemplate.setUsername(USERNAME); mongoTemplate.setPassword(PASSWORD); return mongoTemplate; } // public String getMappingBasePackage() { // return "dist.bo"; // }
but never work if the query isCode:mongoTemplate.updateFirst("entityCollectionName", query(where("name").is("object name")), update("deleted", true));
The funny thing is, retrieving document by id with such query works fine:Code:query(whereId().is(the_document_id)),
I never found any tutorial/reference talking about update a property by query ID.Code:mongoTemplate.findOne(query(whereId().is(the_document_id)), MyDoc.class);
Did I miss something?


Reply With Quote