[2.0-scala] recommended ORM?

5,250 views
Skip to first unread message

Trung Pham

unread,
Sep 20, 2012, 3:24:09 AM9/20/12
to play-fr...@googlegroups.com
What ORM do you recommend to use with Play2 Scala?
Is there anything that is comparable to ActiveRecord/Ruby?

Thanks.

Leon Radley

unread,
Sep 20, 2012, 3:37:46 AM9/20/12
to play-fr...@googlegroups.com
Slick is the future

there are a alot of problems using jpa / hibernate / ebeans with scala because of how the ebean plugin does it's bytecode manipulation.
You can get it working, but it's not recommended from what I've understood

If you're looking for a mongodb orm have a look at salat and my plugin for it http://github.com/leon/play-salat

Cheers!

Ike

unread,
Sep 20, 2012, 2:19:35 PM9/20/12
to play-fr...@googlegroups.com
For Mongo you may also want to look at thew new Reactive Mongo:

Eishay Smith

unread,
Sep 20, 2012, 2:21:03 PM9/20/12
to play-fr...@googlegroups.com
We use circumflex & Play2/Scala http://circumflex.ru/projects/orm/index.html with much success talking with H2 & MySQL DBs.
The big pluses are with flexibility and extensibility. 

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/fGSCFWR3KzIJ.

To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

Giovanni

unread,
Sep 20, 2012, 8:12:34 PM9/20/12
to play-fr...@googlegroups.com
What about Anorm?

I know that Anorm is not an ORM. The Play documentation suggests to use Anorm, instead of an ORM.

What do you think?

Jeroen Kransen

unread,
Oct 4, 2012, 5:22:11 AM10/4/12
to play-fr...@googlegroups.com
I don't get why Anorm is the default persistence framework mentioned in the Play/Scala documentation. Documentation about it is pretty much non-existent, and questions about it remain unanswered. And technically, why precisely is OO not the best fit for Scala (according to Play documentation)? The whole idea about Scala is that you get functional programming without giving up OO programming. And really when I get a class Foo, and I do a getBar to another class, I want a lazy fetch right then, and not tailor every possible query combination in advance.

By the way, in the book "Manning - Play for Scala" (MEAP, early access, not published yet), besides Anorm another framework is discussed: Squeryl.

Op vrijdag 21 september 2012 02:12:43 UTC+2 schreef Giovanni het volgende:

James Roper

unread,
Oct 4, 2012, 7:00:17 PM10/4/12
to play-fr...@googlegroups.com
I don't think it's so much that OO is not the best fit for Scala, more that it's OO is not the best fit for relational databases.  ORM frameworks like JPA put a lot of effort into trying to match them up, but it continually confuses developers, and you have to understand so much about the magic going on underneath that isn't in your code in order to achieve even the simplest tasks.  But, in Java, we use these frameworks because the alternative is massive amounts of error prone boiler plate code.  In Scala, we don't have this problem, mapping between rows and case classes can be done very easily with minimal boiler plate, creating and populating queries can also be done with minimal boiler plate.  So, why bother with the complexity of mapping a relational database to OO in Scala when the biggest benefits, the reduction of boiler plate, don't apply?

Paulo "JCranky" Siqueira

unread,
Oct 7, 2012, 11:53:54 AM10/7/12
to play-fr...@googlegroups.com

About Anorm, isn't it about not having loads of as well?

Besides that, an additional question: any plans to move towards Slick, perhaps as the official thingie, after Scala 2.10 is out?

[]s,

Paulo "JCranky" Siqueira
http://jcranky.com
http://lojinha.paulosiqueira.com.br

To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/FYy4L8mnxe0J.

Paulo "JCranky" Siqueira

unread,
Oct 7, 2012, 11:54:24 AM10/7/12
to play-fr...@googlegroups.com

I meant loads of  state.... sorry

sas

unread,
Oct 7, 2012, 12:17:12 PM10/7/12
to play-fr...@googlegroups.com
yeap, interesting question

are you evaluating the possibility of moving to slick with play 2.1???

saludos

sas

anli

unread,
Oct 7, 2012, 12:29:40 PM10/7/12
to play-fr...@googlegroups.com
For me an absence of play branch working under scala 2.10 (which is required by slick) is the main (and, probably, the only) stopper for evaluating typesafe efforts.

Yann Simon

unread,
Oct 7, 2012, 2:56:11 PM10/7/12
to play-fr...@googlegroups.com
Then you will be happy to know that play 2.1 master has migrated to scala 2.10

2012/10/7 anli <andrew....@gmail.com>:
> For me an absence of play branch working under scala 2.10 (which is required
> by slick) is the main (and, probably, the only) stopper for evaluating
> typesafe efforts.
>
> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/oG3v0MXtH-EJ.

anli

unread,
Oct 7, 2012, 4:30:13 PM10/7/12
to play-fr...@googlegroups.com
On Sunday, October 7, 2012 10:56:40 PM UTC+4, Yann Simon wrote:
Then you will be happy to know that play 2.1 master has migrated to scala 2.10


Be sure I am :) - thanks. Have built (via ./build and 'package' inside sbt - without 'experimental' system property which is still defined in project build file but isn't used), tried and got the error shown below. Have I missed something?

zz $ play new 1st
       _            _
 _ __ | | __ _ _  _| |
| '_ \| |/ _' | || |_|
|  __/|_|\____|\__ (_)
|_|            |__/

play! 2.1-SNAPSHOT (using Scala 2.10.0-M7), http://www.playframework.org

The new application will be created in /wrk/zz/1st

What is the application name?
> 1st

Which template do you want to use for this new application?

  1             - Create a simple Scala application
  2             - Create a simple Java application
  3             - Create an empty project
  <g8 template> - Create an app based on the g8 template hosted on Github

> 1
java.lang.NoSuchMethodError: scalax.io.Input.string$default$1()Lscalax/io/Codec;
        at play.console.Console$.replace(Console.scala:29)
        at play.console.Console$.generateLocalTemplate(Console.scala:61)
        at play.console.Console$.newCommand(Console.scala:133)
        at play.console.Console$$anonfun$10$$anonfun$apply$5.apply(Console.scala:182)
        at play.console.Console$$anonfun$10$$anonfun$apply$5.apply(Console.scala:182)
        at play.console.Console$$anonfun$11.apply(Console.scala:185)
        at play.console.Console$$anonfun$11.apply(Console.scala:184)
        at scala.Option.map(Option.scala:133)
        at play.console.Console$.main(Console.scala:184)
        at play.console.Console.run(Console.scala:208)
        at play.console.Console.run(Console.scala:205)
        at xsbt.boot.Launch$.run(Launch.scala:55)
        at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
        at xsbt.boot.Launch$.launch(Launch.scala:69)
        at xsbt.boot.Launch$.apply(Launch.scala:16)
        at xsbt.boot.Boot$.runImpl(Boot.scala:31)
        at xsbt.boot.Boot$.main(Boot.scala:20)                                                                                                                     
        at xsbt.boot.Boot.main(Boot.scala)                                                                                                                         
Error during sbt execution: java.lang.NoSuchMethodError: scalax.io.Input.string$default$1()Lscalax/io/Codec;                                                       
zz $          

James Roper

unread,
Oct 7, 2012, 10:19:23 PM10/7/12
to play-fr...@googlegroups.com

Besides that, an additional question: any plans to move towards Slick, perhaps as the official thingie, after Scala 2.10 is out?

Absolutely. First step is upgrade to 2.10.  We are very close to finishing this.

Yann Simon

unread,
Oct 8, 2012, 3:11:03 PM10/8/12
to play-fr...@googlegroups.com
2012/10/7 anli <andrew....@gmail.com>:
I confirm this bug.
Opening existing projects work on the other hand.

ouertani slim

unread,
Oct 9, 2012, 12:13:15 PM10/9/12
to play-fr...@googlegroups.com
I posted a tutorial using slick and playframework 2.1  ( dev version)  here  http://www.jroller.com/ouertani/entry/getting_started_with_play_2

Slim Ouertani

Giovanni

unread,
Oct 9, 2012, 8:47:37 PM10/9/12
to play-fr...@googlegroups.com
I saw the tutorial. It seems very good. I will try to build a project following the tutorial.

I am now chosing the technologies to use in a new project at my company.
I already decided to use Scala, Akka, Play.

I have some doubt about the persistence layer: Anorm or Slick?

Will Slick be the future standard for Play?




--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/dHINr2EwSGUJ.

Julien Richard-Foy

unread,
Oct 10, 2012, 4:04:04 AM10/10/12
to play-fr...@googlegroups.com
> I have some doubt about the persistence layer: Anorm or Slick?

I think you should try both and pick the one which with you’re the
more comfortable. Slick and Anorm are very similar in a sense that
both aren’t ORM.

> Will Slick be the future standard for Play?

I’m not sure to understand well your question: whatever you choose,
Anorm or Slick, their integration with Play is very straightforward,
right?

Giovanni

unread,
Oct 10, 2012, 8:45:06 PM10/10/12
to play-fr...@googlegroups.com
> Will Slick be the future standard for Play?

I’m not sure to understand well your question: whatever you choose,
Anorm or Slick, their integration with Play is very straightforward,
right?

Yes, I mean that question.

Giovanni

unread,
Oct 11, 2012, 8:29:54 PM10/11/12
to play-fr...@googlegroups.com
Yes, I agree with Sarvesh.

In my case I am trying to introduce the Typesafe stack (Scala, Akka, Play) into my company. If I don't make the "right" choice, later my boss will not trust me anymore and I can have risk for my job. I am not joking.

So I have to be very careful to introduce new technologies that can have a long support in the future.

That's why I asked about the "future of play". Probably the main developers of Play have some ideas in their mind about the future direction for the persistence layer. If you can share your thoughts, probably you can help many application developers to make the "right" choice.

Best regards,
giovanni


On Thu, Oct 11, 2012 at 12:40 PM, Sarvesh Kumar Singh <sarve...@gmail.com> wrote:
I agree that the use of both of them will be straight forward.. but I think that we
can safely assume that there will be various ( I mean way more than right now )
community available modules for play in near future.

Now most of them will be using the default database approach ( if may be Anorm
or Slick depending on how the devs goes), now in this case the point of knowing
the "future of play" in terms of default database approach becomes important.

More-ever there is already almost zero documentation for Anorm and if Play drops it in future
then Anorm is sure to reach absolute zero and anyone having their important apps written in using
Anorm will have to switch.

Considering these points I think that this is a pretty important question ( specially for start-ups with
few programmers).

Regards,
Sarvesh
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/zKpSCGKVi_cJ.

John Castle

unread,
Oct 13, 2012, 6:42:55 AM10/13/12
to play-fr...@googlegroups.com
Considering that Slick is now a part of Typesafe like Play, I think it is safe to assume that the integration will be straightfoward and that it will be used as a default. But don't take my word for it and do your own research :)

Erem Boto

unread,
Oct 14, 2012, 5:04:33 PM10/14/12
to play-fr...@googlegroups.com
Squeryl is awesome for an ORM and type-safe query language. For the most part it just stays out of the way of your models. The 0.9.6 version will be even better when it starts using typeclasses for object persistence. Then your models will need literally no ORM annotation, which is sweet.

Slick looks like a really nice alternative to anorm for processing resultsets from hand-written SQL, but its ORM syntax looks more obtrusive than Squeryl's IMHO. Also it won't be available in your Play applications unless you're using 2.1-SNAPSHOT.

The downside to Squeryl is that it has no real institutional support, which makes me nervous using it, but the few developers on the project are excellent and very responsive.

Erem

Will Sargent

unread,
Oct 14, 2012, 7:17:37 PM10/14/12
to play-fr...@googlegroups.com
On Sun, Oct 14, 2012 at 2:04 PM, Erem Boto <er...@egraphs.com> wrote:
> Squeryl is awesome for an ORM and type-safe query language. For the most
> part it just stays out of the way of your models. The 0.9.6 version will be
> even better when it starts using typeclasses for object persistence. Then
> your models will need literally no ORM annotation, which is sweet.

One thing to note is that Squeryl doesn't support collection
semantics, such as list, set or tree (i.e. you can't get items as a
Seq, change their order around and have positions it mapped through
the collection, a la Hibernate.) You're working with one to many
associations and many to many associations of Scala objects.

Will.

Sarvesh Kumar Singh

unread,
Oct 15, 2012, 4:35:45 AM10/15/12
to play-fr...@googlegroups.com
Has anyone used Activate -> http://activate-framework.org/ with play ?

felipeko

unread,
Oct 15, 2012, 9:08:44 AM10/15/12
to play-fr...@googlegroups.com
Hi, 

I've been using Activate successfully on my project so far, it's greatly integrated with scala, so i can use traits and it just works. 
As i've been developing i had no problems so far with it as a ORM, it saves and updates accordingly without any problems and without me thinking about it. And it's really a pleasure to not have to think about it.

The main problem, and is a big pain, is that it doesn't integrate very well with play reloader, so you have to restart play on every server-side change..
I've got a fast computer, so i can live with it. 

But i've been talking with Flavio, Activate's developer, and he is trying to solve this problem, and also trying to add a lot of cool stuff, such as polyglot persistence, which can be very helpful in the future.

Flávio W. Brasil

unread,
Nov 21, 2012, 9:19:45 PM11/21/12
to play-fr...@googlegroups.com
Hello.

Activate 1.1 is available with play reloader support! :)


-- 
Flávio W. Brasil
{persistence as it should be}

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/1K-BDSoNUyIJ.

Kostas kougios

unread,
Apr 2, 2013, 3:56:45 PM4/2/13
to play-fr...@googlegroups.com
Bit late answer but anyway here it goes:

If you're interested in a domain-model centric ORM that maps your domain model (no matter how complex or simple) to tables, then try mapperdao:

https://code.google.com/p/mapperdao/

It is just a jar (maven & sbt dependencies are available for scala 2.9 and 2.10). It doesn't couple your domain classes with the ORM tool and has almost as many features as hibernate. I believe the beauty of it is that there is no ORM-related code in your domain classes and you don't have to modify your domain model to fit your database.

Anyway, I have a pdf tutorial here:

https://mapperdao-examples.googlecode.com/files/tutorial-1.0.0-rc15.pdf

and a lot of examples here:

https://code.google.com/p/mapperdao-examples/
Message has been deleted
Message has been deleted

Shishir Lamichhane

unread,
Apr 15, 2013, 8:13:04 AM4/15/13
to play-fr...@googlegroups.com
Hi, I have created a basic sample for the configuration of Play 2.1.1 Framework, Scala 2.10 Language, Spring3 for dependency injection and Hibernate4 as ORM.

Log4j.jar is used for logging.

Checkout the project : https://github.com/ceecer1/play211-scala210-spring3-Hibernate4.git

Edit the following to suit your db requirement in spring-context-data.xml.

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="org.postgresql.Driver"/>
        <property name="url" value="jdbc:postgresql://localhost:5432/scalaspringhibernate"/>
        <property name="username" value="test"/>
        <property name="password" value="test"/>
    </bean>


cmd -> play run

Creates tables in the database.

Insert 1 or 2 rows manually in the User table after the db is created.

Change <prop key="hibernate.hbm2ddl.auto">
create</prop> to update

got to : http://localhost:9000/ and see the JSON result

This might be really helpful for you guys.

Enjoy SCALA.

Thanks,
ceecer.l...@gmail.com

Sebastian Scarano

unread,
Apr 15, 2013, 9:06:04 AM4/15/13
to play-fr...@googlegroups.com
I remember when Play 2 was released that the them decided to got with ebean because it was more compatible with the way Play worked than hibernate (which seems to have some problem with the state)

Anybody knows the pros/cons of using hibernate from play scala?

And if there's no con, how come it's not more widely used in play???

saludos

sas

--
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/5Yj-Pb08GlM/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Shishir Lamichhane

unread,
Apr 15, 2013, 10:10:55 AM4/15/13
to play-fr...@googlegroups.com
It's only my perception.

Play is moving completely towards Scala leaving Java. And the fact that Hibernate was created for java, not for Scala. Using Hibernate with Play may not utilize JVM in an efficient way, rather using frameworks and libs solely built using Scala which would use JVM in more efficient way. So the play team has recommended Ebean or Anorm than java frameworks.

Luis Ángel Vicente Sánchez

unread,
Apr 15, 2013, 10:20:36 AM4/15/13
to play-fr...@googlegroups.com
Ebean is a java framework:

http://www.avaje.org/

And play allows you to create your own plugins to use Hibernate or whatever other framework you want. I don't actually see that moving towards scala.

2013/4/15 Shishir Lamichhane <ceecer.l...@gmail.com>
It's only my perception.

Play is moving completely towards Scala leaving Java. And the fact that Hibernate was created for java, not for Scala. Using Hibernate with Play may not utilize JVM in an efficient way, rather using frameworks and libs solely built using Scala which would use JVM in more efficient way. So the play team has recommended Ebean or Anorm than java frameworks.

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.

Kevin Meredith

unread,
Dec 9, 2013, 12:52:07 PM12/9/13
to play-fr...@googlegroups.com
Hi James -

Do you have any other reading material to elaborate on your ORM claims as "the alternative is massive amounts of error prone boiler plate?"

Thanks,
Kevin


On Thursday, October 4, 2012 7:00:17 PM UTC-4, James Roper wrote:
I don't think it's so much that OO is not the best fit for Scala, more that it's OO is not the best fit for relational databases.  ORM frameworks like JPA put a lot of effort into trying to match them up, but it continually confuses developers, and you have to understand so much about the magic going on underneath that isn't in your code in order to achieve even the simplest tasks.  But, in Java, we use these frameworks because the alternative is massive amounts of error prone boiler plate code.  In Scala, we don't have this problem, mapping between rows and case classes can be done very easily with minimal boiler plate, creating and populating queries can also be done with minimal boiler plate.  So, why bother with the complexity of mapping a relational database to OO in Scala when the biggest benefits, the reduction of boiler plate, don't apply?

On Thursday, 4 October 2012 19:22:11 UTC+10, Jeroen Kransen wrote:
I don't get why Anorm is the default persistence framework mentioned in the Play/Scala documentation. Documentation about it is pretty much non-existent, and questions about it remain unanswered. And technically, why precisely is OO not the best fit for Scala (according to Play documentation)? The whole idea about Scala is that you get functional programming without giving up OO programming. And really when I get a class Foo, and I do a getBar to another class, I want a lazy fetch right then, and not tailor every possible query combination in advance.

By the way, in the book "Manning - Play for Scala" (MEAP, early access, not published yet), besides Anorm another framework is discussed: Squeryl.

Op vrijdag 21 september 2012 02:12:43 UTC+2 schreef Giovanni het volgende:
What about Anorm?

I know that Anorm is not an ORM. The Play documentation suggests to use Anorm, instead of an ORM.

What do you think?


On Fri, Sep 21, 2012 at 2:21 AM, Eishay Smith <eis...@gmail.com> wrote:
We use circumflex & Play2/Scala http://circumflex.ru/projects/orm/index.html with much success talking with H2 & MySQL DBs.
The big pluses are with flexibility and extensibility. 
On Thu, Sep 20, 2012 at 12:37 AM, Leon Radley <le...@radley.se> wrote:
Slick is the future

there are a alot of problems using jpa / hibernate / ebeans with scala because of how the ebean plugin does it's bytecode manipulation.
You can get it working, but it's not recommended from what I've understood

If you're looking for a mongodb orm have a look at salat and my plugin for it http://github.com/leon/play-salat

Cheers!

On Thursday, September 20, 2012 9:24:09 AM UTC+2, Trung Pham wrote:
What ORM do you recommend to use with Play2 Scala?
Is there anything that is comparable to ActiveRecord/Ruby?

Thanks.

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/fGSCFWR3KzIJ.

To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

--
You received this message because you are subscribed to the Google Groups "play-framework" group.

thoefer

unread,
Dec 9, 2013, 3:07:33 PM12/9/13
to play-fr...@googlegroups.com
I completely agree with James Roper´s first comment on orm strategy in play. I use anorm with mapped case classes which together makes some kind of data mapper pattern really intuitive and scalable even for larger applications. It feels almost as scala/play has some integrated support for this pattern.
Reply all
Reply to author
Forward
0 new messages