Your SlideShare is downloading. ×
Mongo db with spring data document
Mongo db with spring data document
Mongo db with spring data document
Mongo db with spring data document
Mongo db with spring data document
Mongo db with spring data document
Mongo db with spring data document
Mongo db with spring data document
Mongo db with spring data document
Mongo db with spring data document
Mongo db with spring data document
Mongo db with spring data document
Mongo db with spring data document
Mongo db with spring data document
Mongo db with spring data document
Mongo db with spring data document
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Mongo db with spring data document

3,930

Published on

Published in: Technology, Business
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,930
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
47
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. MongoDB with Spring Data Document Sean@Weaveus May 2011Monday, May 9, 2011 1
  • 2. <<interface>> @Autowired Mongo Operations Bean Mongo Template Bean MongoDB DriverMonday, May 9, 2011 2
  • 3. 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
  • 4. 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
  • 5. 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
  • 6. 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
  • 7. Document CRUDMonday, May 9, 2011 7
  • 8. Save > db.things.save({ name: "mongo" }) > t = { x : 3 } { "x" : 3 } > db.things.save(t)Monday, May 9, 2011 8
  • 9. 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
  • 10. 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
  • 11. with Spring DataMonday, May 9, 2011 11
  • 12. MongoTemplate • Document databases extension to Spring Programming Model • SPEL • DataException hierarchy • IoC ConfigurationMonday, May 9, 2011 12
  • 13. Beans @Configuration or XML-BasedMonday, May 9, 2011 13
  • 14. <<interface>> Mongo Mongo @Autowired Repository Operations Mongo Criteria Bean Mongo Template Bean MongoDB DriverMonday, May 9, 2011 14
  • 15. Object-Document Implicit ConversionMonday, May 9, 2011 15
  • 16. • MongoRepository • Method name based Query • @Query, QueryDSL • Criteria, Predication Support • GPS Query • Mapping • @Document(Instead of @Entity) • Asynchronous CallbackMonday, May 9, 2011 16

×