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.

Taming NoSQL with Spring Data

4,295 views

Published on

Enterprise applications are complex making it difficult to fit everything in one model. NoSQL is taking a leading role in the next generation database technologies and polyglot persistence a good option to leverage the strength of multiple data stores. This talk will introduce the Spring Data project, an umbrella project that provides a familiar and consistent Spring-based programming model for a wide range of data access technologies such as Redis, MongoDB, HBase, Neo4j...while retaining store-specific features and capabilities.

Published in: Technology
  • Visit Here to Download PDF Format === http://pdfasgoasasga.qpoe.com/B00HTC8MA2-the-everything-nordic-cookbook-includes-spring-nettle-soup-norwegian-flatbread-swedish-pancakes-poached-salmon-with-green-sauce-cloudberry-mousse-and-hundreds-more-by-schoening-diehl-kari-2012-paperback.html
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Follow the link, new dating source: ❶❶❶ http://bit.ly/2F90ZZC ❶❶❶
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating direct: ❶❶❶ http://bit.ly/2F90ZZC ❶❶❶
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Taming NoSQL with Spring Data

  1. 1. Taming NoSQL with Spring Sergi Almar @sergialmar
  2. 2. About Sergi Almar‣CTO @ PayTouch‣VMWare / SpringSource CertifiedInstructor‣javaHispano JUG core member‣Spring I/O organizer (hope to see you nextyear in Spain)
  3. 3. Database evolution 1990$ RDBS$
  4. 4. Database evolution 1990$ 2000# RDBS# RDBS$ OLAP#/# BI#
  5. 5. Database evolution 1990$ 2000# 2010$ RDBS$ RDBS# NoSQL$ RDBS$ OLAP$/$BI$ OLAP#/# BI# Hadoop$
  6. 6. Increasing Cost & Complexity
  7. 7. CAP Theorem
  8. 8. CAP Theorem Hypertable HBase BigTable MongoDB RDBMS Redis Memcache Couchbase Terrastore Dynamo Voldemort Cassandra Riak SimpleDB CouchDB
  9. 9. CAP Theorem Dynamo Voldemort Cassandra RDBMS Riak SimpleDB CouchDB Which one should I choose? Hypertable HBase BigTable MongoDB Redis Memcache Couchbase Terrastore
  10. 10. NoSQL Categories Key-Value Column Document Graph
  11. 11. Welcome to Polyglot persistence
  12. 12. Key-Value Stores
  13. 13. Key-value stores‣Based on Amazon’s Dynamo paper‣Data stored as key / value pairs‣Hard to query‣Mostly in memory K1 V1 K2 V2 K3 V2
  14. 14. ‣Redis is an advanced key-value store ‣Similar to Memcached but the dataset is not volatile. ‣Data types: string, lists, sets, hashes, sorted sets ‣Data expiration‣Master-slave replication‣Has “transactions” (batch operations)‣Libraries - Many languages (Java: Jedis,JRedis...)
  15. 15. Redis Quick Demo
  16. 16. Column stores
  17. 17. Column storesBased on Bigtable paperData model: big table with columnfamilies
  18. 18. Document store
  19. 19. Table / Documents { title: "Taming NoSQL with Spring Data", abstract: "NoSQL is taking a leading ...", speaker: "Sergi Almar", topics: ["nosql", "spring"]}
  20. 20. Documents { amount: 33, currency: "EUR", user: { first_name: "Sergi", last_name: "Almar" }, payment : { cc: "2342", expiracy: "11/12" }, fingerprints : [{ index: "right_index", score: 94}, { index: "right_middle", score: 89}] }
  21. 21. ‣JSON-style documents‣Full or partial document updates‣GridFS for efficiently storing large files‣Index support - secondary andcompound‣Rich query language for dynamic queries‣Map / Reduce‣Replication and auto sharding
  22. 22. RDBMS MongoDB• Table • Collection• Row • JSON Document• Index • Index• Join • Embedding &• Partition Linking• Partition Key • Shard • Shard Key
  23. 23. MongoDB Quick Demo
  24. 24. Graph stores
  25. 25. ‣DB is a collection of graph nodes,relationships ‣Nodes and relationships have properties‣Query is done via a traversal API‣Indexes on node / relationshipproperties‣Written in Java, can be embedded‣Transactions (ACID)
  26. 26. Spring Data
  27. 27. Spring Data http://www.springsource.com/spring- data‣An umbrella project for:‣JPA - Repositories‣JDBC Extensions‣MongoDB - Document Database‣Neo4J - Graph Database‣Redis, Riak - Key Value Database‣Gemfire - Distributes Data Grid‣Hadoop / HBase - Big Data Storage andAnalysis platform
  28. 28. Spring Data Building Blocks‣Mapping of POJOs to underlying datamodel‣Familiar Spring ‘Template’ ‣MongoTemplate, RedisTemplate, Neo4JTemplate...‣Generic Repository support
  29. 29. Spring Data Repositories IpublicinterfaceRepository<T,IDextendsSerializable>{!}publicinterfaceCrudRepository<T,IDextendsSerializable>extendsRepository<T,ID>{!Tsave(Tentity);Iterable<T>save(Iterable<?extendsT>entities);TfindOne(IDid);!booleanexists(IDid);!Iterable<T>findAll();!longcount();!voiddelete(IDid);!voiddelete(Tentity);voiddelete(Iterable<?extendsT>entities);!voiddeleteAll();}
  30. 30. Spring Data Repositories IIpublicinterfacePagingAndSortingRepository<T,IDextendsSerializable>extendsCrudRepository<T,ID>{Iterable<T>findAll(Sortsort);Page<T>findAll(Pageablepageable);}publicinterfacePersonRepositoryextendsCrudRepository<Person,BigInteger>{//FinderforasingleentityPersonfindByEmailAddress(StringemailAddress);//FinderformultipleentitiesList<Person>findByLastnameLike(StringlastName);//FinderwithpaginationPage<Person>findByFirstnameLike(StringfirstName,Pageablepage);}
  31. 31. Spring Data JPA I@EntitypublicclassPerson{@Id@GeneratedValue(strategy=GenerationType.AUTO)&privateBigIntegerid;privateStringfirstname,lastname;@Column(name="email")privateStringemailAddress;@OneToManyprivateSet<Person>colleagues;}By just defining the interface, Spring provides the implementation<jpa:repositories,base.package="com.java2days.repository"2/>!
  32. 32. Spring Data JPA II‣Query methods use method namingconventions ‣ Can override with Query annotation ‣ Or method name references a JPA namedpublicinterfacePersonRepositoryextendsCrudRepository<Person,BigInteger>{//previousmethodsomitted… query!@Query("select!p!from!Person!p!where!p.emailAddress!=!?1")!!Person!findByEmailAddress(String!emailAddress);!!!!!@Query("select!p!from!Person!p!where!p.firstname!=!:firstname!or!p.lastname!=!:lastname")!!Person!findByLastnameOrFirstname(@Param("lastname")!String!lastname,!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!@Param("firstname")!String!firstname);}
  33. 33. Spring Data Key-ValueKey-Value Column Document Graph MongoDB
  34. 34. Spring Data‣MongoTemplate‣Object-Document Mapping‣Repository Support‣QueryDSL‣JMX‣Logging‣GeoSpatial‣Spring XML namespace
  35. 35. Spring Data MongoDB - Entity Mapping
  36. 36. Spring Data MongoTemplate
  37. 37. Spring MongoDB Template usage
  38. 38. Spring Data MongoDB Repository{ location : { $near : [point.x, point.y], $maxDistance : distance}}
  39. 39. publicinterfacePersonRepositoryextendsPagingAndSortingRepository<Person,String>{List<Person>findByLastName(StringlastName);List<Person>findByFirstName(StringlastName);List<Person>findByByShippingAdresses(Addressaddress);List<Person>findByByFirstNameAndLastName(Stringfn,Stringln);List<Person>findByByFirstNameAndLastName(Stringfn,Stringln,PageRequestpagingInfo);}
  40. 40. publicinterfacePersonRepositoryextendsPagingAndSortingRepository<Person,String>{List<Person>findByLastName(StringlastName);List<Person>findByFirstName(StringlastName);List<Person>findByByShippingAdresses(Addressaddress);List<Person>findByByFirstNameAndLastName(Stringfn,Stringln);List<Person>findByByFirstNameAndLastName(Stringfn,Stringln,PageRequestpagingInfo);}Keyword Sample Logical resultGreaterThan findByAgeGreaterThan(int age) {"age" : {"$gt" : age}}LessThan findByAgeLessThan(int age) {"age" : {"$lt" : age}}Between findByAgeBetween(int from, int to) {"age" : {"$gt" : from, "$lt" : to}}NotNull findByFirstnameNotNull() {”firstname" : {"$ne" : null}}Null findByFirstnameNull() {”firstname" : null}Like findByFirstnameLike(String name) "firstname" : firstname} (regex)
  41. 41. Spring Data Mongo Repository usage
  42. 42. Spring Data Key-ValueKey-Value Column Document Graph Redis, Riak
  43. 43. Spring Data Redis‣Portable API across several Redis connectors‣RedisTemplate ‣Access all Redis functionality, dedicated interfaces for each data type ‣Value / Hash / Set / ZSet / List Operations ‣Handles serialization and type conversion automatically ‣String specific class through StringRedisTemplate (JSON, XML...) ‣Fluent Query API‣Async Pub / Sub support with MLC‣Spring 3.1 Cache Abstraction provider
  44. 44. Redis Configuration (Jedis connector)<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd<bean id="jedisConnectionFactory" class="org.springframework.data.keyvalue.redis.connection.jedis.JedisConnect p:use-pool="true" p:host-name="server" p:port="6379"/><!-- redis template definition --><bean id="redisTemplate" class="org.springframework.data.keyvalue.redis.core.RedisTemplate" p:connection-factory-ref="jedisConnectionFactory"/>...</beans>
  45. 45. Using RedisTemplateredisTemplate.opsForValue().get(“user:salmar:transactions”);redisTemplate.opsForValue().set(“user:salmar:transactions”, 20);redisTemplate.opsForValue().increment(“user:salmar:transactions”, 1);redisTemplate.opsForSets().add(“user:salmar:friends”, “jlong”);redisTemplate.opsForSets().intersect(“user:salmar:friends”, “user.jlong:friends”);
  46. 46. Thank you! Q&A @sergialmar

×