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.
NoSQL in Enterprise Java ApplicationsPatrick BaumgartnerNoSQL Search Roadshow | Munich | 16.04.2013
2Agenda• Speaker Profile• New Demands on Data Access• New Types of Data Stores• Polyglot Persistence• Integrating NoSQL Da...
3Speaker ProfilePatrick Baumgartner• Senior Software Consultant | Partner @ Swiftmind• Spring Framework, OSGi, Neo4j• Spri...
4SwiftmindYour experts for Enterprise JavaAreas of expertise• Java EE• Spring Framework• OSGi• Agile Methodologies• Softwa...
5New Demands on Data Access• Structured andunstructured data• Massive amounts of data• Inexpensive horizontalscaling• Apps...
6New Types of Data Stores
7NoSQLData SizeData ComplexityKey-Value StoresColumn FamilyDocument DatabasesGraph DatabasesRelational Databases90%
8One single data store for your application?Polyglot Persistence
9Polyglot PersistenceWeb ShopUser Sessions Shopping Card RecommendationsProduct Catalog Analytics Financial DataRedis Riak...
10We are not architects!Integrating NoSQL Data Stores #1http://www.flickr.com/photos/sakeeb/4087246274
11Don’t re-invent the wheel!Integrating NoSQL Data Stores #2http://www.flickr.com/photos/dmott9/5921728819
12Let’s use Spring!Integrating NoSQL Data Stores #3http://www.springsource.org/spring-data
13Spring Data• Same goals as the Spring Framework– Productivity improvement– Programming model consistency– Portability• U...
14Spring Data – Overview #1• JPA• JDBC ExtensionsRelational Databases• Apache HadoopBig Data• GemFireData Grid• RESTHTTP• ...
15Spring Data – Overview #2• Mongo DB• Couchbase *Document Stores• Neo4JGraph Databases• HbaseColumn Stores• Apache Solr *...
16Spring Data – Key Features• Low level data access API abstraction– MongoTemplate, RiakTemplate, Neo4jTemplate …– Excepti...
17Spring Data MongoDB – Example
18DocumentsStored JSON:{ "_id" : ObjectId("4f9886290364b533b3acd4ce"),"_class" : "com.acme.hello.domain.Person","name" : "...
19Spring Data MongoDB – DocumentStored JSON:{ "_id" : ObjectId("4f9886290364b533b3acd4ce"),"_class" : "com.example.Person"...
20Spring Data MongoDB – Configuration
21Spring Data MongoDB – Repository@Repositorypublic class MongoPersonRepository implements BaseRepository<Person> {@Autowi...
22Spring Data MongoDB – Repository #2@Repositorypublic interface MongoPersonRepository implements CrudRepository<Person, L...
23Spring Data Neo4j – Example
24Graph
25Social DataAliceCarol LukeBobSamPete
26The only use case?Social Graph
27Spatial Data12 53138type:Hotelname:Radisson Blulat:47.452549long:8.564615type:Hotelname:Widderlat:47.373517long:8.539252
28Social & Spatial DataAliceMat 5Bob138type:Hotelname:Radisson Blulat:47.452549long:8.564615
29Financial DataAliceHotel LukeBankATMPete
30Your business domainProcessKPIDeviceActivityFunctionService
31Spring Data Neo4j (SDN)• POJOs mapped as nodes or relationships – type safe• Works directly Database, typically embedded...
32Spring Data Neo4j – NodeEntity_type_: com.example.Personname: "Alice"age: 42@NodeEntitypublic class Person {private Stri...
33Spring Data Neo4j – Relationship@RelationshipEntitypublic class Knows {private int sinceYear;public Knows since(int year...
34Spring Data Neo4j – NodeEntity@NodeEntitypublic class Person {private String name;private int yearOfBirth;@RelatedTo(typ...
35Spring Data Neo4j – Repositorypublic interface PersonRepository extendsGraphRepository<Person> {@Query("start person = {...
36Spring Data Neo4j – Querying• Several possibilities implemented to query the graph– Neo4j API– Traversal descriptions– G...
37Highlights and Challenges
38Highlights• Vibrating community, great support on mailing lists• Using the right tool for the right job• New technologie...
39Challenges• Developer Onboarding• Schema changes -> migrations• Some topics not solved yet -> e.g. versioning• Not many ...
40Information from the sourceSpring DataHive Pig JDBC HBase JPASplunk NoSQL Redis BigDataHadoop Redis Roo GemfireMongoDB N...
41Use a data model which really matches to your data …Give it a try!http://www.flickr.com/photos/juniorvelo/3267647833
42Q&A
43Thank you!Patrick Baumgartner, @patbaumgartnerpatrick.baumgartner [at] swiftmind [dot] comhttp://www.swiftmind.com @swif...
Upcoming SlideShare
Loading in …5
×

No Sql in Enterprise Java Applications

Related Books

Free with a 30 day trial from Scribd

See all
  • Be the first to comment

No Sql in Enterprise Java Applications

  1. 1. NoSQL in Enterprise Java ApplicationsPatrick BaumgartnerNoSQL Search Roadshow | Munich | 16.04.2013
  2. 2. 2Agenda• Speaker Profile• New Demands on Data Access• New Types of Data Stores• Polyglot Persistence• Integrating NoSQL Data Stores• Spring Data Overview• Example with MongoDB• Example with Neo4j• Highlights and Challenges• Q & A
  3. 3. 3Speaker ProfilePatrick Baumgartner• Senior Software Consultant | Partner @ Swiftmind• Spring Framework, OSGi, Neo4j• Spring Trainer• Co-Autor von „OSGi für Praktiker“• Agile Methodologies & Practices• Scrum.org Trainer - PSD Java• @patbaumgartner
  4. 4. 4SwiftmindYour experts for Enterprise JavaAreas of expertise• Java EE• Spring Framework• OSGi• Agile Methodologies• Software Engineering Best PracticesHeadquarter• Zürich, Schweiz• @swiftmind• http://www.swiftmind.com
  5. 5. 5New Demands on Data Access• Structured andunstructured data• Massive amounts of data• Inexpensive horizontalscaling• Apps and data in thecloud• Social network features• …
  6. 6. 6New Types of Data Stores
  7. 7. 7NoSQLData SizeData ComplexityKey-Value StoresColumn FamilyDocument DatabasesGraph DatabasesRelational Databases90%
  8. 8. 8One single data store for your application?Polyglot Persistence
  9. 9. 9Polyglot PersistenceWeb ShopUser Sessions Shopping Card RecommendationsProduct Catalog Analytics Financial DataRedis Riak Neo4jMongoDB Casandra MySQL
  10. 10. 10We are not architects!Integrating NoSQL Data Stores #1http://www.flickr.com/photos/sakeeb/4087246274
  11. 11. 11Don’t re-invent the wheel!Integrating NoSQL Data Stores #2http://www.flickr.com/photos/dmott9/5921728819
  12. 12. 12Let’s use Spring!Integrating NoSQL Data Stores #3http://www.springsource.org/spring-data
  13. 13. 13Spring Data• Same goals as the Spring Framework– Productivity improvement– Programming model consistency– Portability• Umbrella for subprojects, specific to a given database• Mapping support for Java domain objects• http://www.springsource.org/spring-data• http://github.com/SpringSource/spring-data-XXX
  14. 14. 14Spring Data – Overview #1• JPA• JDBC ExtensionsRelational Databases• Apache HadoopBig Data• GemFireData Grid• RESTHTTP• RedisKey Value Stores
  15. 15. 15Spring Data – Overview #2• Mongo DB• Couchbase *Document Stores• Neo4JGraph Databases• HbaseColumn Stores• Apache Solr *• Elastic Search *Search• CommonsCommon Infrastructure* Community Project
  16. 16. 16Spring Data – Key Features• Low level data access API abstraction– MongoTemplate, RiakTemplate, Neo4jTemplate …– Exception translation– Transaction management• Object Mapping (Java to data store)• Generic Repository Support– Basic CRUD, dynamic finders, pagination and sorting• Spring namespaces• Cross Store Persistence Programming Model– @Entity, @Document, @NodeEntity …
  17. 17. 17Spring Data MongoDB – Example
  18. 18. 18DocumentsStored JSON:{ "_id" : ObjectId("4f9886290364b533b3acd4ce"),"_class" : "com.acme.hello.domain.Person","name" : "Bob","age" : 33}
  19. 19. 19Spring Data MongoDB – DocumentStored JSON:{ "_id" : ObjectId("4f9886290364b533b3acd4ce"),"_class" : "com.example.Person","name" : "Bob","age" : 33}@Documentpublic class Person {@Idprivate int id;private String name;private int age;// getters/setters…}
  20. 20. 20Spring Data MongoDB – Configuration
  21. 21. 21Spring Data MongoDB – Repository@Repositorypublic class MongoPersonRepository implements BaseRepository<Person> {@AutowiredMongoOperations mongoTemplate;Person createPerson(String name, int age){if(!mongoTemplate.collectionExists(Person.class)){mongoTemplate.createCollection(Person.class);}Person p = new Person(name, age);mongoTemplate.insert(p)return p;}...}
  22. 22. 22Spring Data MongoDB – Repository #2@Repositorypublic interface MongoPersonRepository implements CrudRepository<Person, Long>{Page<Person> findByNameContaining(String name, Pageable p);@Query("{ ?0 : ?1 }")List<Product> findByAttributes(String key, String value);}
  23. 23. 23Spring Data Neo4j – Example
  24. 24. 24Graph
  25. 25. 25Social DataAliceCarol LukeBobSamPete
  26. 26. 26The only use case?Social Graph
  27. 27. 27Spatial Data12 53138type:Hotelname:Radisson Blulat:47.452549long:8.564615type:Hotelname:Widderlat:47.373517long:8.539252
  28. 28. 28Social & Spatial DataAliceMat 5Bob138type:Hotelname:Radisson Blulat:47.452549long:8.564615
  29. 29. 29Financial DataAliceHotel LukeBankATMPete
  30. 30. 30Your business domainProcessKPIDeviceActivityFunctionService
  31. 31. 31Spring Data Neo4j (SDN)• POJOs mapped as nodes or relationships – type safe• Works directly Database, typically embedded mode• Data is fetched very fast and lazy• Stores everything within a @Transaction• Uses heavily AspectJ magic to enhance the POJOs• …
  32. 32. 32Spring Data Neo4j – NodeEntity_type_: com.example.Personname: "Alice"age: 42@NodeEntitypublic class Person {private String name;private int age;// getters/setters…}Person alice = new Person();alice.setName("Alice");alice.setAge(42);alice.persist();Node
  33. 33. 33Spring Data Neo4j – Relationship@RelationshipEntitypublic class Knows {private int sinceYear;public Knows since(int year) {this.sinceYear = year;return this;}}@NodeEntitypublic class Person {public Known knows(Person p) {return this.relateTo(p, Knows.class, "KNOWS");}}Person alice = ...;Person bob ...;alice.knows(bob).since(2012); Alice BobKNOWSsince: 2012
  34. 34. 34Spring Data Neo4j – NodeEntity@NodeEntitypublic class Person {private String name;private int yearOfBirth;@RelatedTo(type = "KNOWS", direction = Direction.OUTGOING)private Set<Person> knownPersons;public void knows(Person p) {knownPersons.add(p);}public Set<Person> getFriends() {return knownPersons;}}Person alice = ...;alice.knows(bob);alice.knows(carol);Alice BobKNOWSCarolKNOWS
  35. 35. 35Spring Data Neo4j – Repositorypublic interface PersonRepository extendsGraphRepository<Person> {@Query("start person = {0} match ... return ...")Iterable<Product> getOwnedServices(Person person);Iterable<Person> findByName(String name);Iterable<Person> findByNameLike(String name);}@AutowiredPersonRepository personRepository;Person alice = personRepository.findByName("Alice");
  36. 36. 36Spring Data Neo4j – Querying• Several possibilities implemented to query the graph– Neo4j API– Traversal descriptions– Graph algorithms– Index queries– Cypher queries
  37. 37. 37Highlights and Challenges
  38. 38. 38Highlights• Vibrating community, great support on mailing lists• Using the right tool for the right job• New technologies differentiate our product/service fromcompetitors• Sources on github.com – Pull requests for improvements• Very good overall performance• We can use Spring!• Abstraction layer makes “driver” changes easy
  39. 39. 39Challenges• Developer Onboarding• Schema changes -> migrations• Some topics not solved yet -> e.g. versioning• Not many show cases documented in detail• Sizing for scaling based on real world measurements• Massive amount of data• Several framework and data store releases per year• Bugs, but no show stoppers• Keeping documentation up-to-date, data model changes
  40. 40. 40Information from the sourceSpring DataHive Pig JDBC HBase JPASplunk NoSQL Redis BigDataHadoop Redis Roo GemfireMongoDB Neo4j REST exporterQuerydsl Repositorieshttp://bit.ly/sd-book
  41. 41. 41Use a data model which really matches to your data …Give it a try!http://www.flickr.com/photos/juniorvelo/3267647833
  42. 42. 42Q&A
  43. 43. 43Thank you!Patrick Baumgartner, @patbaumgartnerpatrick.baumgartner [at] swiftmind [dot] comhttp://www.swiftmind.com @swiftmind

    Be the first to comment

    Login to see the comments

  • jmau2002

    Oct. 28, 2015
  • ranreply

    Jun. 29, 2016

Views

Total views

1,030

On Slideshare

0

From embeds

0

Number of embeds

170

Actions

Downloads

12

Shares

0

Comments

0

Likes

2

×