4 ms·
Play uses Ebean on the Java side of the fence. Anorm is for Scala users. Here's how to do a query for a person in Anorm: SQL("select * from person where id = {
by mark242 14y ago
Play uses Ebean on the Java side of the fence. Anorm is for Scala users. Here's how to do a query for a person in Anorm:
SQL("select * from person where id = {id}").on("id" -> myAgeVariable).map(row => MyPersonObject(row[String]("name"), row[Int]("age"))).toList
...returns you a list of MyPersonObjects. No need for JPA bindings or any other annotations. Based on type safety, you must have the method MyPersonObject.apply(name: String, age: Int) or else the compiler will error. It's a great way of catching SQL funkiness inside your IDE.
- alexatkeplar 14y agoYech, embedding raw SQL strings in a typesafe, compiled language like Scala is so full of fail it's not funny. Hopefully they'll switch out Anorm for Slick (which is also a Typesafe project - http://slick.typesafe.com/ http://slick.typesafe.com/) soon.
- codewright 14y agoEbean vs. Anorm vs. Slick is a good example of why I don't like using full-stack frameworks. When I use minimalist web frameworks, I get to use best-of-class libraries across the board, not make decisions based on damage control. Examples of minimalist web frameworks: Sinatra, Flask, Scalatra, Ring/Compojure
- tommi 14y agoThere's nothing blocking from using Slick or any ORM in Play.
- alexatkeplar 14y agoYep, I do like the Ring/Compojure philosophy. Actually we just open-sourced a pixel server based on Ring/Compojure yesterday (https://github.com/snowplow/snowplow/tree/master/2-collectors/clojure-collector https://github.com/snowplow/snowplow/tree/master/2-collector...)