6

Scala 的数据库访问框架:Slick 3.0 移除了 session 相关的 API

 3 years ago
source link: https://tianchunfeng.blog.csdn.net/article/details/49150657
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Scala 的数据库访问框架:Slick 3.0 移除了 session 相关的 API

original.png
田春峰 2015-10-15 11:49:19 articleReadEyes.png 3280

Scala 的数据库访问框架:Slick 3.0 移除了 session 相关的 API

Slick 3 对于 Slick 2 的改变相当于 Python 3 至于 Python 2 的改变。
Slick 3 的新特性集中在 :大量使用组合的设计模式,不需要显式声明session,非阻塞,stream支持的 reactive 等 。
不过我最喜欢这个方法: setFetchSize 。
具体来说:
在Scala slick 2.x 中:
db.withSession{
   implicit session =>
     query.run
在Scala slick 3.x 中需要替换为:
query.result.run(db)
def foo(implicit session: Session): ... = {
   query.run
db.withSession(foo)
需要替换为:
def foo: DBIO[...] = query.result
foo.run(db)
更多的例子,可以参考这里:
从Slick 2.X 迁移到 Slick 3.X

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK