Example for using Neo4j with Grails
In reply to my today’s annoncement of the Neo4j Grails plugin, @StigLau asked me to provide an example for using the Neo4j Grails plugin. So here we go:
- Create your sample application:
grails create-app neo4jtest; cd neo4jtest - Remove the hibernate plugin:
grails uninstall-plugin hibernate
- Add the Neo4j plugin:
grails install-plugin neo4j
- create some sample domain classes:
grails create-domain-class Author grails create-domain-class Book
- create a controller for the domain class
grails create-controller Author grails create-controller Book
- modify the domain classes:
class Author { String name Date dob static hasMany = [ books: Book ] }
and
class Book { String title static belongsTo = [author:Author] }
- modify the controller to use dynamic scaffolding:
class AuthorController { def scaffold = true }
class BookController { def scaffold = true }
- start up the application:
grails run-app - use it, love it: go to http://localhost:8080/neo4jtest, add some authors and books.
- to explore the Neo4j node space created with your grails app, check out Neoclipse.
UPDATE: Use Grails 1.2 -M2 or M3. This will not work with the current stable Grails 1.1.1 version.

Great to see some code, thanks!
/peter
Hello from Russia!
Can I quote a post in your blog with the link to you?
Hi Polprav, quoting is allowed of course.