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

  • Leightweight MongoDB support

    Hi,
    we are happily using Spring Data with MongoDB. It's great, but we have one problem. Our use-case is a bit different than the common one. We have our own Object/JSON mapping tools so we want to use everything from Spring Data except the mapping. Unfortunately it's almost impossible to use MongoTemplate without Spring Data provided Object/JSON mapping. Would it be possible to change the template in a way that would allow us to send/retreive JSON (or BSON) directly?

    Currently we are using a workaround when we re-implement most methods using MongoTemplate.doInCollection(). It's easier than without Spring Data but I think that direct JSON support would be handy.

    Regards
    Lukas


    Code:
     public void insert(final DBObject value) {
            mongoTemplate.execute(collectionName, new CollectionCallback<Void>() {
                @Override
                public Void doInCollection(DBCollection collection)  throws MongoException, DataAccessException {
                    collection.insert(value);
                    return null;
                }
            });
        }
Working...
X