5

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 ?
Robin des Bois
  • 355
  • 2
  • 6
  • 20

1 Answers1

3

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.

Eve Freeman
  • 32,467
  • 4
  • 86
  • 101
  • AFAIK Scala is used in Neo4j internally to implement Cypher. Do you know if Neo Technology or any other party (maybe you, Typesafe or cakesolutions?) has interest to come up with an open source OGM for Scala? If yes: Where should I ask for it? I think can live with Spring and ignore the unidiomatic @annotation approach (when I get it working...). Anyway I think it would be really nice to have something made for Scala... Unitl then an Activator template using Play and Spring Data Neo4j would be a temporary solution. Similar to https://typesafe.com/activator/template/play-spring-data-jpa – Robin des Bois Jul 22 '14 at 11:59
  • AFAIK Spring Data Neo4j has bad performance over REST. If you want to use SD 100% then moving to an unmanaged extension might be only way to use that together with a hosted Neo4j instance in server mode. – albertoperdomo Jul 22 '14 at 15:49
  • 1
    There is also a new Play Plugin that uses SD internally, but I don't know how good it works over REST: https://github.com/tuxBurner/play-neo4jplugin – albertoperdomo Jul 22 '14 at 15:57
  • Thanks for the tipp. I will look into the play-neo4jplugin! I also heard about the bad performance over rest. Will this issue be addressed in the next time? – Robin des Bois Jul 22 '14 at 16:59