Benefits of type-safe library (Morphia) -


i'm thinking use morphia gwt mongodb project i'm wondering benefits of type-safe library morphia? thanks

it's type-safe. no, kidding aside, morphia api nicer interact with.

to save entity plain java driver you'd this:

dbcollection table = db.getcollection("user"); basicdbobject document = new basicdbobject(); document.put("name", "xeraa"); document.put("age", 30); document.put("createddate", new date()); table.insert(document); 

so putting plain dbobjects - inserting, updating, , querying this:

basicdbobject searchquery = new basicdbobject(); searchquery.put("age", "30"); dbcursor cursor = table.find(searchquery); 

in morphia annotate entities in jpa fashion:

@entity class fooentity {     private string name;     private integer age;     private date date = new date(); } 

so create objects , persist them. fluent query interface nicer can things ds.createquery(fooentity.class).field("age").equal(30).aslist();


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -