Your SlideShare is downloading. ×
Neo4J and Grails
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Neo4J and Grails


Published on

Published in: Technology
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Rapid development with Neo4J under Grails
  • 2. About Myself• Located in Riga/Latvia• Technical Architect in Accenture• Experience since 10 years• C#/Java/Groovy/Scala/Erlang
  • 3. no:sqlMarket has significantly different challenges indealing with data that the traditional RDBMSsolutions could not cope with.
  • 4. Issues• size data sets• data relations are connected• distributed processing• Data Model -> semi-structured approach
  • 5. brings to diversity of solutions Data Model Distribution Disk Data Model Structure
  • 6. types Document store Graph Key-value storeMultivalue databases Object database Tabular Tuple store
  • 7. hard to integrate in industrialized companies
  • 8. Grails SupportName TypeRIAK Eventually‐consistent key‐value +REDIS Key-value cache in RAM +MemcacheDB Ordered key-value stores +-Apache CouchDB Document store +MongoDB Document store +Apache Hadoop Tabular/Big Table +Apache Cassandra Eventually‐consistent key‐value +Neo4J Graph +
  • 9. Graph DB implemetations LanguageDEX C++FlockDB ScalaInfiniteGraph JavaHyperGraphDB JavaNeo4J JavaOpenLink Virtuoso C++, C#, Java, SPARQLOrientDB JavaSones GraphDB C#
  • 10. Graph on(in) GrailsNeo4j is (as of now) the only graph databasethat fits nicely in a Grails application.
  • 11. Data is connected
  • 12. Why Graph DB?Insufficient RDBMS performance in hierarchicalstructures. The graph database storage shineswhen storing richly-connected data. Querying isperformed through traversals, which canperform millions of traversal steps per second. Atraversal step resembles a join in a RDBMS.
  • 13. SQL addonsSome DBs has even special DSL:SELECT empno, ename, job, mgr, hiredate, LEVELFROM empWHERE LEVEL <= 2START WITH mgr IS NULLCONNECT BY PRIOR empno = mgr
  • 14. Where Graph DB• Network Management• Master Data Management• Social• Finance• Spatial – Map Routing• Bio
  • 15. Why Neo4J?• true ACID transactions• high availability• scales to billions of nodes and relationships• high speed querying through traversals• well documented• Java• licenses
  • 16. Why neo4j - details• Disk ready – Native graph storage engine with custom (SSD- ready) binary on-disk format• Transactional – JTA/JTS, XA, 2PC, Tx Recovery, deadlock detection …• Scalable – Billions of nodes on single JVM
  • 17. Access & Implementation Types1. EmbeddedGraphDatabase: just to local JVM2. RestGraphDatabase: rest-binding3. HighAvaibleGraphDatabase: uses Zookeeper
  • 18. When Grails shinesRuby platform isn’t a case, Java is too expensive,Scala is too smart.Startups & prototypesModel-driven architecture where GORM isfundament.
  • 19. Groovy & Grails Architecture Controller View GSP Service Domain Plug-in Gant GORM Site Mesh Spring Hibernate DB Java EE Groovy JVM
  • 20. GORMAbstraction on abstractions, wraps: – Hibernate – JPA – Gemfire, Redis, Riak – MongoDB, JCR – Neo4JIntegration testing via TCK
  • 21. Neo4j plug-in
  • 22. Plugin features• Neo4j -> Groovy/Java• GORM dynamic finders, criteria and named queries• Session-managed transactions• Bean Validation• Neo4js traversal• Embedded, REST and HA
  • 23. Jump into Neo4J name:staff type:weaponname:SplinterfullName:Hamato Yoshitype: rat type: interact type:knows name:Shredder fullName:Oroku Saki
  • 24. Nodes
  • 25. Relationships
  • 26. Properties name:staff type:weaponname:SplinterfullName:Hamato Yoshitype: rat type: interact type:knows
  • 27. Mapping Reference Node SubreferenceDomain Class/Type SubreferenceNode Domain Class Instance Instance Domain Class Properties Instance Properties Assocoation
  • 28. Compatibility with GORM ✔ ✗Simple persistence methods HQL queriesDynamic finders Dirty checking methodsCriteria queries Composite primary keysNamed queries Any direct interaction with the Hibernate APIInheritance Custom Hibernate user typesEmbedded typesQuery by exampleMany-to-many associations (these can bemodelled with a mapping class)
  • 29. Getting Startedgrails install-plugin neo4jgrails uninstall-plugin hibernate
  • 30. Create Domaingrails create-domain-class Hero
  • 31. 100 )Hero.findAllByFullNameNotNull()hero.weapons.each { …}
  • 32. Combining Neo4j And Hibernatestatic mapWith = "neo4j”def hibernateHero = Hero.get(1) neo4jHero = Person.neo4j.get(1)
  • 33. Advanced Configurationgrails-app/conf/DataSource.groovy grails { neo4j { type = "embedded" location = "/var/neo4j" params = [] } }
  • 34. Via RESTtype = "rest”grails { neo4j { type = "rest" location = "http://localhost:7474/db/data/" }}
  • 35. High Availabiletype = "ha”grails { neo4j { type = "ha" location = "/var/neo4j" params = [ // see ha.server_id: 1, ha.coordinators: localhost:2181,localhost:2182,localhost:2183 ] }}
  • 36. Referencesno:sql http://neo4j.orggrails-neo4j plug-in mapping/neo4j/manual/guide/index.html
  • 37. QuestionsQ are guaranteed in life – answers aren’t.