xlukas
Sep 19th, 2011, 06:37 AM
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
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;
}
});
}
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
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;
}
});
}