Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

MongoDB + Java + Spring Data

Related Books

Free with a 30 day trial from Scribd

See all
  • Be the first to comment

MongoDB + Java + Spring Data

  1. 1. MongoDB + JAVA + Spring dataAnton SulzhenkoJava Software EngineerAnton_Sulzhenko@epam.com
  2. 2. MongoDB + Java + Spring Data MongoDB Java Spring Data
  3. 3. 3 MongoDB Java Spring DataWhat is NoSQL?• Non-relational data• Schemaless• No JOINs, No complex transactions• Horizontal scalability
  4. 4. 4 MongoDB Java Spring Data• Key-value(Redis, MemcaheDB)• Wide column(BigTable, Cassandra, HBase)• Document(MongoDB, CouchDB, Riak)• Graph(Neo4j, FlockDB)
  5. 5. 5MongoDB Java Spring Data
  6. 6. MongoDBDocumented-oriented database
  7. 7. 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. 8. 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. 9. 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
  10. 10. 10MongoDB + Java + Spring Data MongoDB Java Spring Data
  11. 11. 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. 12. 12 MongoDB Java Spring DataMongoDB Java Driver Usage
  13. 13. 13MongoDB + Java + Spring Data MongoDB Java Spring Data
  14. 14. SPRING DATAMongoDB
  15. 15. 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. 16. 16 MongoDB Java Spring DataInstantiating MongoTemplate using XML based metadata:
  17. 17. 17 MongoDB Java Spring DataSample CRUD operations using MongoTemplate:
  18. 18. 18 MongoDB Java Spring Data Mapping annotation overview:• @Id• @Document• @DBRef• @Indexed• @CompoundIndex• @GeoSpatialIndexed• @Transient• @PersistenceConstructor• @Value
  19. 19. 19MongoDB Java Spring Data
  20. 20. 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. 21. 21 MongoDB Java Spring DataSpring Data MongoDB: Repositories
  22. 22. 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. 23. 23 MongoDB Java Spring DataSpring Data MongoDB: Repositories
  24. 24. 24 MongoDB Java Spring Data• Map/Reduce / Aggregation framework• Index management• Support for GridFS• Geospatial indexes/queries• Optimistic Locking
  25. 25. 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. 26. 26 Questions? MongoDB Java Spring DataAnton Sulzhenko Anton_Sulzhenko@epam.com

    Be the first to comment

    Login to see the comments

  • yongkyu

    Jul. 15, 2014
  • PatrykGolabek

    Aug. 27, 2014
  • ssuser4a734e

    Oct. 25, 2014
  • pvz1976

    Feb. 1, 2015
  • ericpeladan

    Feb. 16, 2015
  • bunkertor

    Mar. 15, 2015
  • seunghaeom

    Apr. 2, 2015
  • joobn

    Apr. 4, 2015
  • anhdet1989

    Apr. 16, 2015
  • HMrles

    Jul. 2, 2015
  • smanjunath1

    Sep. 30, 2015
  • yordchaia

    Oct. 16, 2015
  • meriamb01

    Oct. 28, 2015
  • ViswamDevireddy

    Mar. 13, 2017
  • mcmarone

    May. 29, 2017
  • sbastutan

    Aug. 12, 2017
  • rmouadeu

    May. 9, 2018
  • natraghu

    Sep. 25, 2019
  • ecassamc

    Sep. 26, 2020
  • amandhuppar1

    Jun. 25, 2021

Views

Total views

15,444

On Slideshare

0

From embeds

0

Number of embeds

46

Actions

Downloads

0

Shares

0

Comments

0

Likes

27

×