Tags » Mongo

I blogged a kick start tutorial on Mongo dB last week, I strongly recommend going through this article if you are a beginner or intend to start leaning Mongo. 321 more words

Mongo

MongoDB : Script to run Sharding with replica set on local machine

This simple script will help to you run sharing with multiple replica set on your local box. This makes very cool and uplifting, (if on linux use sudo / root to run shell script or commands manually. 479 more words

Sailor Boy - Pilot Bread

This modern day version of hardtack, albeit with some leavening and shortening, is produced today by Interbake Foods of Richmond, Virginia.    Alaskan law requires all… 681 more words

Mongo

Third Time is a Charm

Another one buddy”, Dad asked ask he scooped up another pile for this morning’s walk. Dad knew something was amiss with Mongo. Mongo is typically a digestive machine. 316 more words

Mongo

Convert Mongo DBObject to POJO with Jongo


import org.jongo.ResultHandler;
import org.jongo.bson.Bson;
import org.jongo.bson.BsonDocument;
import org.jongo.marshall.Unmarshaller;
import org.jongo.marshall.jackson.JacksonEngine;
import org.jongo.marshall.jackson.configuration.Mapping;

...

    public Pojo getPojo(DBObject dbObject) {
        JacksonEngine engine = new JacksonEngine(new Mapping.Builder().build());
        ResultHandler<Pojo> handler = new UnmarshallingResultHandler<>(engine, Pojo.class); 
        Pojo pojo = handler.map(dbObject);
        return pojo;
    }

    public static class UnmarshallingResultHandler<T> implements ResultHandler<T> {
        private final Unmarshaller unmarshaller;
        private final Class<T> clazz;
        public UnmarshallingResultHandler(Unmarshaller unmarshaller, Class<T> clazz) {
            this.unmarshaller = unmarshaller;
            this.clazz = clazz;
        }
        public T map(DBObject result) {
            BsonDocument bsonDocument = Bson.createDocument(result);
            return unmarshaller.unmarshall(bsonDocument, clazz);
        }
    }

Java Programming

It’s more than a month blog has an updates, I followed updating blog twice a month as part of my last year’s resolution , and I did. 1,216 more words

Mongo