Announcement Announcement Module
Collapse
No announcement yet.
MongoDB Unstructued Data Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MongoDB Unstructued Data

    How do you reference unstructured, multi-level data (as a Map) in Spring Data Document MongoDB?

    I'm trying to represent the following object:
    Code:
    {
      '_id': (Object ID Here)
      'name': 'john',
      'data': {
                 'pet': 'cat',
                 'other': ['some', 'stuff'],
                 'more': { 'unstructured': 'info' }
               }
    }
    With the following class:
    Code:
    @Document
    public class Person {
      ObjectId id;
      String name;
      Map<String, Object> data; // Schemaless data for which I do not know the structure
    }
    Right now I get an Exception in MappingMongoConverter.findTypeToBeUsed because it tries to call [dbObject.get(CUSTOM_TYPE_KEY)] on a `DBArray` (because 'other' is a `DBArray`)

    Any ideas? Or is this just a bug?

  • #2
    Good question..

    I am also curious about this. The mapping supported currently seems to fit the Object Mapping requirements, but it's not clear in the examples that I've seen, at least, how this can be used to map onto more arbitrary collections within mongo.

    Perhaps somebody has an example to show this concept and how the Spring Data -> Mongo interaction would take place?

    Comment


    • #3
      Fixed!

      Just so everyone knows, the bug in my original post was filed and quickly fixed: https://jira.springsource.org/browse/DATADOC-235

      Thanks, Oliver!

      Comment

      Working...
      X