• Save
MongoDB + Java + Spring Data
Upcoming SlideShare
Loading in...5

MongoDB + Java + Spring Data






Total Views
Views on SlideShare
Embed Views



1 Embed 2

https://twitter.com 2


Upload Details

Uploaded via as Microsoft PowerPoint

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.

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

MongoDB + Java + Spring Data MongoDB + Java + Spring Data Presentation Transcript

  • MongoDB + JAVA + Spring dataAnton SulzhenkoJava Software EngineerAnton_Sulzhenko@epam.com
  • MongoDB + Java + Spring Data MongoDB Java Spring Data
  • 3 MongoDB Java Spring DataWhat is NoSQL?• Non-relational data• Schemaless• No JOINs, No complex transactions• Horizontal scalability
  • 4 MongoDB Java Spring Data• Key-value(Redis, MemcaheDB)• Wide column(BigTable, Cassandra, HBase)• Document(MongoDB, CouchDB, Riak)• Graph(Neo4j, FlockDB)
  • 5MongoDB Java Spring Data
  • MongoDBDocumented-oriented database
  • 7 MongoDB Java Spring Data MongoDB TerminologyRDBMS Mongo DBDatabase DatabaseTable CollectionRow JSON documentColumn FieldIndex IndexJoin Embedded documents & linkingAggregation (e.g. group by) Aggregation framework
  • 8 MongoDB Java Spring DataMongoDB Features• JSON data model with dynamic schemas• CRUD operations• Atomic document operations• Ad hoq Queries like SQL (equality, regexp, ranges, geospatial)• Full, flexible index support• Auto-sharding for horizontal scalability• Built-in replication and high availability
  • 9 MongoDB Java Spring DataMongoDB Drivers• One wire protocol for all client languages• A driver implementation per language• Responsibilities: - Converting language dependent data structures <-> BSON - Generating ObjectId for _id field
  • 10MongoDB + Java + Spring Data MongoDB Java Spring Data
  • 11 MongoDB Java Spring DataMongoDB Java Driver Features• CRUD• Support for replica sets• Connection pooling• Distributed reads to slave servers• BSON serializerdesirializer• JSON serializerdesirializer• GridFS
  • 12 MongoDB Java Spring DataMongoDB Java Driver Usage
  • 13MongoDB + Java + Spring Data MongoDB Java Spring Data
  • 15 MongoDB Java Spring DataSpring Data MongoDB• Templating • Resource abstraction • Configure connections to mongod/mongos node(s) • Collection lifecycle (create/drop) • Map/Reduce / Aggregation• Object mapping • Annotation based: @Document, @Field, @Index etc. • Classes are mapped to collections, Java Objects to documents• Repository Support • Queries are derived from method signatures • Geospatial Queries
  • 16 MongoDB Java Spring DataInstantiating MongoTemplate using XML based metadata:
  • 17 MongoDB Java Spring DataSample CRUD operations using MongoTemplate:
  • 18 MongoDB Java Spring Data Mapping annotation overview:• @Id• @Document• @DBRef• @Indexed• @CompoundIndex• @GeoSpatialIndexed• @Transient• @PersistenceConstructor• @Value
  • 19MongoDB Java Spring Data
  • 20 MongoDB Java Spring DataSpring Data MongoDB: Repositories• Main concept: • Use the signature of a method to derive the query(at runtime)• Base implementations / abstractions for • CRUD operations • Paging • Sorting
  • 21 MongoDB Java Spring DataSpring Data MongoDB: Repositories
  • 22 MongoDB Java Spring Data Spring Data MongoDB: Repositories Supported keywords for query methods: Keyword Logical resultGreaterThan {"age" : {"$gt" : age}}LessThan {"age" : {"$lt" : age}}Between {"age" : {"$gt" : from, "$lt" : to}}IsNotNull, NotNull {"age" : {"$ne" : null}}IsNull, Null {"age" : null}Like {"age" : age} ( age as regex)(No keyword) {"age" : name}Not {"age" : {"$ne" : name}}Near {"location" : {"$near" : [x,y]}}Within {"location" : {"$within" : {"$center" : [ [x, y], distance]}}}Within {"location" : {"$within" : {"$box" : [ [x1, y1], x2, y2]}}}
  • 23 MongoDB Java Spring DataSpring Data MongoDB: Repositories
  • 24 MongoDB Java Spring Data• Map/Reduce / Aggregation framework• Index management• Support for GridFS• Geospatial indexes/queries• Optimistic Locking
  • 25 MongoDB Java Spring Data• 10gen Education • https://education.10gen.com/• Spring Data - MongoDB • http://www.springsource.org/spring-data/mongodb• The Little MongoDB Book • http://openmymind.net/2011/3/28/The-Little-MongoDB-Book/
  • 26 Questions? MongoDB Java Spring DataAnton Sulzhenko Anton_Sulzhenko@epam.com