Results 1 to 3 of 3

Thread: MongoDB Unstructued Data

  1. #1
    Join Date
    Aug 2011
    Posts
    4

    Default 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. #2
    Join Date
    Nov 2004
    Posts
    21

    Default 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?

  3. #3
    Join Date
    Aug 2011
    Posts
    4

    Talking 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!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •