Scala和PostgreSQL的Play框架最适合哪种数据访问选项? [英] Which is best data access options available for Play framework with Scala and PostgreSQL?

查看:119
本文介绍了Scala和PostgreSQL的Play框架最适合哪种数据访问选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有更早的经验和大量可重用的代码/组件,主要是使用Spring MVC,Hibernate,PostgreSQL数据库完成的。

但最近我们正计划开始一个新项目。我们决定在Scala中使用Play框架。我们是Scala的Play框架新手。因此我们无法决定使用什么ORM(对象关系映射)框架。由于许多可重用的代码,我们希望选择Hibernate。

我们发现有关Hibernate的恐怖词语是在Scala中使用Hibernate的JPA,它可能不是最好的方式,它应该被视为遗留和弃用。我们真的很困惑要使用什么?



在寻找可能性时,我们发现了Anorm和Hibernate。可能还有其他框架存在,我们还不知道。

那么请向我们建议使用Scala和PostgreSQL的Play框架?

预先感谢!

解决方案

如果您确实需要ORM,那么JPA可能就是要走的路。这将迫使你有可变域模型类等,但也许这是你愿意接受的折衷。 (就个人而言,我不会)



如果您愿意选择与数据库交谈的其他方式,可以选择以下几种有趣的选项:



下面是一个相当不错的博客文章,它比较了不同的库: http:// manue l.bernhardt.io/2014/02/04/a-quick-tour-of-relational-database-access-with-scala/


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!

解决方案

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/

这篇关于Scala和PostgreSQL的Play框架最适合哪种数据访问选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆