Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Data Neo4j in Play 2.x app using Scala

I am currently working on a web service backed by Neo4j (v2.1.2, hosted on GrapheneDB) and Play (v2.3) using Scala (2.11.1) (hosted on Heroku).

Until now AnormCypher connects the Play app with the Neo4J instance and all things are working as expected.

However using AnormCypher doesn't feel quite right. I have to write a lot boiler plate code to convert the results I get from AnormCypher to the Scala classes which are used for the business logic. I would prefer using something similar to Spring Data Neo4j.

The code in the examples looks very clean to me and I want to try it in project.

All these technologies are new to me so I need some help:

  • How can I use Spring Data Neo4j in the play app (build.sbt, plugin.sbt, ...)?
  • Which difficulties do I have to expect regarding the fact that I am not using the whole Spring stack?
  • Which drawbacks does it have to integrate a Java based framework in a Scala app ?
like image 844
Robin des Bois Avatar asked Oct 20 '22 04:10

Robin des Bois


1 Answers

I apologize for a somewhat incomplete answer but I thought I'd chime in.

I think there's some room for an ORM-like thing in scala, and I was hoping to make the case class conversion from a stream of results automatic (in AnormCypher), but was never able to make it as performant as .map() with a case class constructor inside (and also it didn't work for inner case classes, and a few other caveats). I'd love to put some effort into making it more like Mongo's Salat so it has better case class conversion support.

I was dreaming of syntax like this:

scala> Cypher("RETURN "foo" as foo, "bar" as bar")()[MyCaseClass]
res0: Stream[MyCaseClass](...)

In any case, to your main point, a while back I saw someone at cake solutions figure out how to get spring data neo4j to work in scala: http://www.cakesolutions.net/teamblogs/2012/03/29/neo4j-spring-data-scala

The post is a bit old but may get you started, and give you an idea about how it may be somewhat annoying. I found the @annotation syntax to be unidiomatic in scala.

like image 60
Eve Freeman Avatar answered Oct 27 '22 23:10

Eve Freeman