Announcement Announcement Module
Collapse
No announcement yet.
Error in MongoTemplate update with "_id" key query (snapshot version). Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error in MongoTemplate update with "_id" key query (snapshot version).

    I had been using M3 versión. Since I needed to update for some issues I changed to snapshot version.

    I had some repository methods for update using a query object for "_id" key with value "new ObjectId( idStr )" where idStr is a String like "4e116e9678c498146847399d".

    I have found that the update method (doUpdate) transforms the query DBObject (queryObj) and it is changed from "{ "_id" : { "$oid" : "4e116e9678c498146847399d"}}" to "{ "_id" : { "_class" : "org.bson.types.ObjectId" , "_time" : 1309765270 , "_machine" : 2026149908 , "_inc" : 1749498269 , "_new" : false}}".

    It happens in this piece of code:

    Code:
    for (String key : queryObj.keySet()) {
    	if (idProperty.equals(key)) {
    		// This is an ID field
    		queryObj.put(ID, mongoConverter.maybeConvertObject(queryObj.get(key)));
    		queryObj.removeField(key);
    	} else {
    		queryObj.put(key, mongoConverter.maybeConvertObject(queryObj.get(key)));
    	}
    }
    Then the update doesn't work because it doesn't find the instance to update.

    EDITED: (I've verified that in M3 queryObj is not changed by this piece of code. AbstractMonoConverter.maybeConvertObject, in M3, returns the ObjectId as is because isSimpleType returns true for ObjectId while in snapshot returns false.)

    What's wrong with it? Has been changed the way to call an update or is it a bug in the snapshot?

    Thank you very much.
    Last edited by francadaval; Jul 30th, 2011, 04:24 AM. Reason: Adicional Info.

  • #2
    Hi

    I have the same issue - http://forum.springsource.org/showth...tId-conversion.

    Were you able to resolve this issue ?

    Thanks
    Vishnu

    Comment


    • #3
      This issue is fixed - https://jira.springsource.org/browse/DATADOC-240

      Comment


      • #4
        I'm back to work!!

        Ok, verified, thanks.

        Comment

        Working...
        X