27
MONGO FOR JPA DEVELOPERS JUSTIN LEE SENIOR SOFTWARE DEVELOPER @ SQUARESPACE.COM http://antwerkz.com @evanchooly

MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

MONGO FOR JPA

DEVELOPERSJUSTIN LEE

SENIOR SOFTWARE DEVELOPER @ SQUARESPACE.COM

http://antwerkz.com @evanchooly

Page 2: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

WHO AM I?Java Developer since 1996Currently Sr. Software Engineer atSquarespace.comFormer member of the GlassFish/Grizzly team

Implemented the WebSocket support forGlassFish 3.1.x and 3.2JSR 356 (WebSocket) Expert Group Member

Worked with EE since 2000We built our own ORM

Page 3: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

WHAT IS MONGO?Name derives from "humongous" which mean big(for you non-idiomatic English speakers)It is a scalable, high-performance, open sourceNoSQL databaseWritten in C++Document orientedFully indexableReplication and HAMap ReduceGridFS

Page 4: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

DOCUMENT ORIENTEDIn JPA, one object is typically mapped acrossmultiple cells in one row of a table

sometimes multiple objects with embeddedentities

Documents stored in json-style documentshttp://bsonspec.org)BSON adds some "extra" information todocuments, like length prefixes, that traversalefficient.

Page 5: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

WHAT DOES A DOCUMENT LOOK LIKE?

db.users.find().pretty()

{"_id" : ObjectId("50fdb55a18c650918ee414be"),"className" : "com.antwerkz.jfokus.mongo.model.User","firstName" : "Jules","lastName" : "Winnfield","email" : "[email protected]","addresses" : [{"street" : "1858 N Vermont Ave","city" : "Los Angeles","state" : "CA","zip" : "90027"}]}

Page 6: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

REPLICATION AND HAeventually consistentreplica setssharding

Page 7: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

TO THE SHELL!

Page 8: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

db.product_orders.find({ fulfilled :true })

Page 9: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open
Page 10: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

db.product_orders.find({ fulfilled :true, size : 3 })

Page 11: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open
Page 12: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

db.product_orders.find({ "products.name": { $in : [ "Quadtech", "Biolux" ] } })

Page 13: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open
Page 14: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

db.product_orders.find({ "products.name": "Quadtech" })

Page 15: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open
Page 16: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

db.product_orders.find({ $or : [ { size: 3 }, {fulfilled : false } ] })

Page 17: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open
Page 18: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

db.product_orders.find({ size : 3 })

Page 19: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

db.product_orders.update({ size : 3 }, {$set : { "total" : 400 } } ) ;

db.product_orders.find({ size : 3 })

Page 20: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open
Page 21: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

db.product_orders.update({ size : 3 }, {$push : { "baubles" : { color : "red" }

} } )

Page 22: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open
Page 23: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

db.product_orders.find({ size : 3 })

Page 24: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

TO THE CODE!

Page 25: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

LINKS Mongo Homepage

Morphiahomepage

Morphiafork

JongoDisclaimer: My Stuff

critter

Ophelia

http://www.mongodb.org/http://code.google.com/p/morphia/

https://github.com/jmkgreen/morphia

http://jongo.org

https://github.com/evanchooly/critterhttps://github.com/evanchooly/ophelia

Page 26: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open

MONGO FOR JPA

DEVELOPERSJUSTIN LEE

SENIOR SOFTWARE DEVELOPER @ SQUARESPACE.COM

http://antwerkz.com @evanchooly

Page 27: MONGO FOR JPA DEVELOPERS - Jfokus · WHAT IS MONGO? Name derives from "humongous" which mean big (for you non-idiomatic English speakers) It is a scalable, high-performance, open