15

We have earlier experiences and lots of reusable code/components mostly done using Spring MVC, Hibernate, PostgreSQL database.

But recently we are planning to start a new project. We decided to use Play framework with Scala. We are new in Play framework with Scala. Thus we couldn't decided what ORM (Object-relational mapping) framework to use. Because of many reusable code, we wish to select Hibernate.

We found scary words regarding Hibernate as "JPA using Hibernate in Scala with play it is probably not the best way, and it should be considered as legacy and deprecated". We are really confused what to use?

While searching for possibilities we found Anorm and Hibernate. There could be some other framework exist, that we don't know yet.

So please suggest us what to use for Play framework with Scala and PostgreSQL?

Thanks in advance!

cchantep
  • 9,118
  • 3
  • 30
  • 41
masiboo
  • 4,537
  • 9
  • 75
  • 136

3 Answers3

18

If you definitely want an ORM then JPA is probably the road to go. This will force you to have mutable domain model classes etc. but maybe this is a trade off you are willing to accept. (Personally, I wouldn't)

If you are open to alternative ways to talk to a database there are a few interesting options:

Here is a pretty good blog post that compares different libraries: http://manuel.bernhardt.io/2014/02/04/a-quick-tour-of-relational-database-access-with-scala/

cchantep
  • 9,118
  • 3
  • 30
  • 41
johanandren
  • 11,249
  • 1
  • 25
  • 30
  • "JPA will replace anorm in the Play Framework as the ORM". If Anorm is to be replaced in Play it would be by Slick, and Anorm is not related to the ORM approach. – cchantep Feb 12 '15 at 15:53
  • Timo. Sort of but you wouldn't be able to make use of case classes and all that goodness in Scala. You must be thinking of that JPA will replace Ebean in the Java side of Play. – johanandren Feb 12 '15 at 21:53
1

Take a look at Skinny ORM.

http://skinny-framework.org/documentation/orm.html

http://blog.seratch.net/post/110711051753/skinny-orm-for-play-framework

Skinny ORM is not only highly inspired by Rails ActiveRecord but flexible enough because it is built upon ScalikeJDBC library which is a thin but powerful JDBC wrapper.

http://scalikejdbc.org/

Kazuhiro Sera
  • 1,822
  • 12
  • 15
1

ebean is provided with playframework it look alike JPA but is not JPA, you could make simple query and efficent (streaming, partial update ...)

cyril
  • 872
  • 6
  • 29