Package com.ponysdk.persistency

Examples of com.ponysdk.persistency.Identifiable


        final ObjectMapper mapper = new ObjectMapper();
        final StringWriter jsonOutput = new StringWriter();
        try {
            mapper.writeValue(jsonOutput, object);
            final DBObject dbObject = (DBObject) JSON.parse(jsonOutput.toString());
            final Identifiable m = (Identifiable) object;
            if (m.getID() != null) {
                db.getCollection(nameSpace).findAndModify(new BasicDBObject("_id", m.getID()), dbObject);
            } else {
                final ObjectId id = new ObjectId();
                dbObject.put("_id", id);
                db.getCollection(nameSpace).save(dbObject);
                m.setID(id);
            }
        } catch (final Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

TOP

Related Classes of com.ponysdk.persistency.Identifiable

Copyright © 2018 www.massapicom. 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.