Spring Data MongoDB
  1. Spring Data MongoDB
  2. DATAMONGO-38

The method saveDBObject assumes that the "id" field in the document is of the type ObjectId - results in cast exception when not using autogenerated ids

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0 M1
    • Fix Version/s: 1.0 M2
    • Component/s: Core
    • Labels:
      None

      Issue Links

        Activity

        Hide
        Gunnar Sigurdsson added a comment -

        Reading through MongoTemplate is seems like this is not just an issue with saveDBObject(). Looks like insertDBObjectList() is making incorrect assumptions about ObjectId.

        This is a blocker issue for us in terms of adopting this project. I strongly recommend that a fix for this issue be included in 1.0.0.

        This is discussed here: http://forum.springsource.org/showthread.php?t=104461. From this thread:


        Thanks for the replies. I have spent some time looking at the code, especially MongoTemplate and see the way ObjectId is assumed in several places. However, it seems like a bad implementation decision and an easy thing to fix.

        We are heavily invested in spring and have been using mongo for a while and were hoping to adopt the spring mongo integration asap. This looks like the only blocker.

        We are using Jackson to serialize/deserialize java objects to/from JSON and the mongo java driver to go between JSON and DBObject. It is trivial to hook our Jackson infrastructure into MongoTemplate by implementing the MongoReaderWriter interface. We have already tried this out. This would allow us to keep using Jackson while the spring mongo project comes up with a useable serialization/deserialization mechanism.


        Show
        Gunnar Sigurdsson added a comment - Reading through MongoTemplate is seems like this is not just an issue with saveDBObject(). Looks like insertDBObjectList() is making incorrect assumptions about ObjectId. This is a blocker issue for us in terms of adopting this project. I strongly recommend that a fix for this issue be included in 1.0.0. This is discussed here: http://forum.springsource.org/showthread.php?t=104461 . From this thread: Thanks for the replies. I have spent some time looking at the code, especially MongoTemplate and see the way ObjectId is assumed in several places. However, it seems like a bad implementation decision and an easy thing to fix. We are heavily invested in spring and have been using mongo for a while and were hoping to adopt the spring mongo integration asap. This looks like the only blocker. We are using Jackson to serialize/deserialize java objects to/from JSON and the mongo java driver to go between JSON and DBObject. It is trivial to hook our Jackson infrastructure into MongoTemplate by implementing the MongoReaderWriter interface. We have already tried this out. This would allow us to keep using Jackson while the spring mongo project comes up with a useable serialization/deserialization mechanism.
        Hide
        Oliver Gierke added a comment -

        That should be fixed in the meantime already. Could you please try a SNAPSHOT to see if it works for you?

        Show
        Oliver Gierke added a comment - That should be fixed in the meantime already. Could you please try a SNAPSHOT to see if it works for you?
        Hide
        Thomas Risberg added a comment -

        There was still a cast in the save method. I removed that.

        Show
        Thomas Risberg added a comment - There was still a cast in the save method. I removed that.

          People

          • Assignee:
            Thomas Risberg
            Reporter:
            Mark Pollack
          • Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: