Package com.mongodb

Examples of com.mongodb.DBCollection.save()


                DBObject obj = dbCollection.findOne(query);
                if (obj != null)
                {
                    obj.putAll(documents.get(documentName));

                    dbCollection.save(obj);
                }
                else
                {
                    dbCollection.save(documents.get(documentName));
                }
View Full Code Here


                    dbCollection.save(obj);
                }
                else
                {
                    dbCollection.save(documents.get(documentName));
                }
            }
        }
        else
        {
View Full Code Here

    protected void doSave(Exchange exchange) throws Exception {
        DBCollection dbCol = calculateCollection(exchange);
        DBObject saveObj = exchange.getIn().getMandatoryBody(DBObject.class);

        WriteConcern wc = extractWriteConcern(exchange);
        WriteResult result = wc == null ? dbCol.save(saveObj) : dbCol.save(saveObj, wc);

        prepareResponseMessage(exchange, MongoDbOperation.save);
        // we always return the WriteResult, because whether the getLastError
        // was called or not, the user will have the means to call it or
        // obtain the cached CommandResult
View Full Code Here

    protected void doSave(Exchange exchange) throws Exception {
        DBCollection dbCol = calculateCollection(exchange);
        DBObject saveObj = exchange.getIn().getMandatoryBody(DBObject.class);

        WriteConcern wc = extractWriteConcern(exchange);
        WriteResult result = wc == null ? dbCol.save(saveObj) : dbCol.save(saveObj, wc);

        prepareResponseMessage(exchange, MongoDbOperation.save);
        // we always return the WriteResult, because whether the getLastError
        // was called or not, the user will have the means to call it or
        // obtain the cached CommandResult
View Full Code Here

    protected void doSave(Exchange exchange) throws Exception {
        DBCollection dbCol = calculateCollection(exchange);
        DBObject saveObj = exchange.getIn().getMandatoryBody(DBObject.class);
       
        WriteConcern wc = extractWriteConcern(exchange);
        WriteResult result = wc == null ? dbCol.save(saveObj) : dbCol.save(saveObj, wc);
       
        prepareResponseMessage(exchange, MongoDbOperation.save);
        // we always return the WriteResult, because whether the getLastError was called or not, the user will have the means to call it or
        // obtain the cached CommandResult
        processAndTransferWriteResult(result, exchange);
View Full Code Here

    protected void doSave(Exchange exchange) throws Exception {
        DBCollection dbCol = calculateCollection(exchange);
        DBObject saveObj = exchange.getIn().getMandatoryBody(DBObject.class);
       
        WriteConcern wc = extractWriteConcern(exchange);
        WriteResult result = wc == null ? dbCol.save(saveObj) : dbCol.save(saveObj, wc);
       
        prepareResponseMessage(exchange, MongoDbOperation.save);
        // we always return the WriteResult, because whether the getLastError was called or not, the user will have the means to call it or
        // obtain the cached CommandResult
        processAndTransferWriteResult(result, exchange);
View Full Code Here

        final TravelAgency agency = new TravelAgency();
        agency.setName("Lastminute.com");
        agency.getHotels().add(borgLoaded);

        final BasicDBObject agencyDbObj = (BasicDBObject) getMorphia().toDBObject(agency);
        agencies.save(agencyDbObj);

        final TravelAgency agencyLoaded = getMorphia().fromDBObject(TravelAgency.class,
                                                                    agencies.findOne(new BasicDBObject(Mapper.ID_KEY,
                                                                                                       agencyDbObj.get(Mapper.ID_KEY))),
                                                                    new DefaultEntityCache());
View Full Code Here

        final DBCollection articles = getDb().getCollection("articles");
        getMorphia().map(Article.class).map(Translation.class).map(Circle.class);

        final Article related = new Article();
        final BasicDBObject relatedDbObj = (BasicDBObject) getMorphia().toDBObject(related);
        articles.save(relatedDbObj);

        final Article relatedLoaded = getMorphia().fromDBObject(Article.class,
                                                                articles.findOne(new BasicDBObject(Mapper.ID_KEY,
                                                                                                   relatedDbObj.get(Mapper.ID_KEY))),
                                                                new DefaultEntityCache());
View Full Code Here

        article.setAttribute("myInt", 123);

        article.putRelated("test", relatedLoaded);

        final BasicDBObject articleDbObj = (BasicDBObject) getMorphia().toDBObject(article);
        articles.save(articleDbObj);

        final Article articleLoaded = getMorphia().fromDBObject(Article.class,
                                                                articles.findOne(
                                                                                    new BasicDBObject(Mapper.ID_KEY,
                                                                                                      articleDbObj.get(Mapper.ID_KEY))),
View Full Code Here

        getMorphia().map(RecursiveParent.class).map(RecursiveChild.class);

        final RecursiveParent parent = new RecursiveParent();
        final DBObject parentDbObj = getMorphia().toDBObject(parent);
        stuff.save(parentDbObj);

        final RecursiveChild child = new RecursiveChild();
        final DBObject childDbObj = getMorphia().toDBObject(child);
        stuff.save(childDbObj);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.