• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Mongo db with spring data document
 

Mongo db with spring data document

on

  • 4,350 views

 

Statistics

Views

Total Views
4,350
Views on SlideShare
4,350
Embed Views
0

Actions

Likes
1
Downloads
46
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Mongo db with spring data document Mongo db with spring data document Presentation Transcript

    • MongoDB with Spring Data Document Sean@Weaveus May 2011Monday, May 9, 2011 1
    • <<interface>> @Autowired Mongo Operations Bean Mongo Template Bean MongoDB DriverMonday, May 9, 2011 2
    • DB Collection#1 Collection#2 Document#1 Document#1 Document#2 Document#2 Document#3 Document#3 Document#4 Document#4 Document#5 Document#5 Document := {UniqueID, JSON Document}Monday, May 9, 2011 3
    • Getting Started - Server SeaniMac:tmp sean$ ls mongodb-osx-x86_64-1.8.1.tgz mongodb-osx-x86_64-1.8.1 SeaniMac:tmp sean$ mkdir -p mongodb-data/db SeaniMac:tmp sean$ ./mongodb-osx-x86_64-1.8.1/bin/mongod --dbpath ./ mongodb-data/db Fri May  6 14:16:48 [initandlisten] MongoDB starting ... ...Monday, May 9, 2011 4
    • Getting Started - Client SeaniMac:tmp sean$ ./mongodb-osx-x86_64-1.8.1/bin/mongo MongoDB shell version: 1.8.1 connecting to: test > db.foo.save( { a: 1 } ) > db.foo.find() { "_id" : ObjectId("4dc3855d3044bae59620330d"), "a" : 1 }Monday, May 9, 2011 5
    • Java(Groovy) import com.mongodb.Mongo import com.mongodb.DB import com.mongodb.DBCollection Mongo m = new Mongo() println m.databaseNames DB db = m.getDB("test") println db.collectionNames DBCollection dbcol = db.getCollection("foo") println dbcol.find().next() // DBObject Instance, BSON // results [test, admin, db, foo, local] [foo, system.indexes] [_id:4dc3855d3044bae59620330d, a:1.0]Monday, May 9, 2011 6
    • Document CRUDMonday, May 9, 2011 7
    • Save > db.things.save({ name: "mongo" }) > t = { x : 3 } { "x" : 3 } > db.things.save(t)Monday, May 9, 2011 8
    • Find > db.things.find() { "_id" : ObjectId("4dc399fc3044bae59620330e"), "name" : "mongo" } { "_id" : ObjectId("4dc3a7913044bae59620330f"), "x" : 3 } > var cursor = db.things.find(); > while (cursor.hasNext()) printjson(cursor.next()); { "_id" : ObjectId("4dc399fc3044bae59620330e"), "name" : "mongo" } { "_id" : ObjectId("4dc3a7913044bae59620330f"), "x" : 3 } > db.things.find().forEach( printjson ) { "_id" : ObjectId("4dc399fc3044bae59620330e"), "name" : "mongo" } { "_id" : ObjectId("4dc3a7913044bae59620330f"), "x" : 3 } > db.things.find({name:"mongo"}).forEach( printjson ); { "_id" : ObjectId("4dc399fc3044bae59620330e"), "name" : "mongo" } > db.things.save( {"name":"nosql", "title":"nonRDB"} ) > db.things.find( {name:"nosql"}, {title:true} ).forEach ( printjson ) { "_id" : ObjectId("4dc3ae133044bae596203312"), "title" : "nonRDB" }Monday, May 9, 2011 9
    • Remove > db.things.remove({name:"mongo"}) > db.things.remove({"_id":ObjectId("4dc3ae133044bae596203312")}) > db.things.find()                                              { "_id" : ObjectId("4dc3a7913044bae59620330f"), "x" : 3 }Monday, May 9, 2011 10
    • with Spring DataMonday, May 9, 2011 11
    • MongoTemplate • Document databases extension to Spring Programming Model • SPEL • DataException hierarchy • IoC ConfigurationMonday, May 9, 2011 12
    • Beans @Configuration or XML-BasedMonday, May 9, 2011 13
    • <<interface>> Mongo Mongo @Autowired Repository Operations Mongo Criteria Bean Mongo Template Bean MongoDB DriverMonday, May 9, 2011 14
    • Object-Document Implicit ConversionMonday, May 9, 2011 15
    • • MongoRepository • Method name based Query • @Query, QueryDSL • Criteria, Predication Support • GPS Query • Mapping • @Document(Instead of @Entity) • Asynchronous CallbackMonday, May 9, 2011 16