slick

Slick confused about numThreads and best practice for good performance

女生的网名这么多〃 提交于 2019-11-28 19:18:13
问题 I am using the PlayFrameWork with Slick and using it in a system that is all I/O database heavy. In my application.conf file I have this setting: play { akka { akka.loggers = ["akka.event.slf4j.Slf4jLogger"] loglevel = WARNING actor { default-dispatcher = { fork-join-executor { parallelism-factor = 20.0 } } } } } This obviously gives me 20 threads per core for the play application and as I understand it Slick creates it's own threadpool, is the NumThreads field in Slick mean that that's the

Slick 3.0 Insert and then get Auto Increment Value

依然范特西╮ 提交于 2019-11-28 18:55:35
问题 I have written this code which works perfectly class Items(tag: Tag) extends Table[Item](tag, "ITEMS") { def id = column[Long]("ITEMS_ID", O.PrimaryKey, O.AutoInc) def name = column[String]("ITEMS_NAME") def price = column[Double]("ITEMS_PRICE") def * = (id, name, price) <> ((Item.apply _).tupled, Item.unapply _) } object Shop extends Shop{ val items = TableQuery[Items] val db = Database.forConfig("h2mem1") def create(name: String, price: Double) : Int = { val action = items ++= Seq(Item(0,

How do you update multiple columns using Slick Lifted Embedding?

半城伤御伤魂 提交于 2019-11-28 17:11:13
How do you update multiple columns using Slick Lifted Embedding ? This document doesn't say much. I expected it to be something like this Query(AbilitiesTable).filter((ab: AbilitiesTable.type) => ab.id === ability_id).map((ab: AbilitiesTable.type) => (ab.verb, ab.subject)).update("edit", "doc") expert I figured it out. It should be like this val map = Query(AbilitiesTable) .filter(_.id === ability_id) .map(ab => ab.verb ~ ab.context) map.update(("", "")) Typesafe , why your documentation is so bad ? I have to Google pretty much every silly thing or dig through unit-tests for hours. Please

Slick 3.0-RC3 fails with java.util.concurrent.RejectedExecutionException

假装没事ソ 提交于 2019-11-28 14:13:33
I'm trying to get familiar with Slick 3.0 and Futures (using Scala 2.11.6). I use simple code based on Slick's Multi-DB Cake Pattern example . Why does the following code terminate with an exception and how to fix it? import scala.concurrent.Await import scala.concurrent.duration._ import slick.jdbc.JdbcBackend.Database import scala.concurrent.ExecutionContext.Implicits.global class Dispatcher(db: Database, dal: DAL) { import dal.driver.api._ def init() = { db.run(dal.create) try db.run(dal.stuffTable += Stuff(23,"hi")) finally db.close val x = { try db.run(dal.stuffTable.filter(_.serial ===

How to write database-agnostic Play application and perform first-time database initialization?

时光毁灭记忆、已成空白 提交于 2019-11-28 13:53:35
问题 I'm using Slick with a Play Framework 2.1 and I have some troubles. Given the following entity... package models import scala.slick.driver.PostgresDriver.simple._ case class Account(id: Option[Long], email: String, password: String) object Accounts extends Table[Account]("account") { def id = column[Long]("id", O.PrimaryKey, O.AutoInc) def email = column[String]("email") def password = column[String]("password") def * = id.? ~ email ~ password <> (Account, Account.unapply _) } ...I have to

22 Column limit for procedures

亡梦爱人 提交于 2019-11-28 11:26:34
How can we overcome the 22 limit when calling procedures with Slick? We currently have: val q3 = sql"""call getStatements(${accountNumber})""".as[Transaction] The problem is that we have to return more than 22 columns and Transaction case class cannot have more than 22 columns since when we do JSONFormat we get an error: [error] E:\IdeaProjects\admin\Transaction.scala:59: No unapply or unapplySeq function found [error] implicit val jsonFormat = Json.format[Transaction] Any suggestions? Alright - so if you can actually modify your Transaction case class than there is a better solution than

Scala reflection to instantiate scala.slick.lifted.TableQuery

只谈情不闲聊 提交于 2019-11-28 10:13:46
I have this base trait trait MyBase { type M type T <: Table[M] val query: TableQuery[T] } Where TableQuery is scala.slick.lifted.TableQuery My subclasses instantiate TableQuery like so: type M = Account type T = AccountsTable val query = TableQuery[T] I'd like to instantiate the TableQuery in the base trait, possibly by using a lazy val , i.e. lazy val query: TableQuery[T] = { ... } I've been playing around with reflection, but haven't had much luck. Régis Jean-Gilles If I understand correctly, what you want is to be able to extend MyBase by simply defining M and T but without having to

Slick: query multiple tables/databases with getting column names

雨燕双飞 提交于 2019-11-28 09:31:08
I have methods in my Play app that query database tables with over hundred columns. I can't define case class for each such query, because it would be just ridiculously big and would have to be changed with each alter of the table on the database. I'm using this approach, where result of the query looks like this: Map(columnName1 -> columnVal1, columnName2 -> columnVal2, ...) Example of the code: implicit val getListStringResult = GetResult[List[Any]] ( r => (1 to r.numColumns).map(_ => r.nextObject).toList ) def getSomething(): Map[String, Any] = DB.withSession { val columns = MTable

Slick codegen & tables with > 22 columns

空扰寡人 提交于 2019-11-28 08:48:33
I'm new to Slick. I'm creating a test suite for a Java application with Scala, ScalaTest and Slick. I'm using slick to prepare data before the test and to do assertions on the data after the test. The database used has some tables with more than 22 columns. I use slick-codegen to generate my schema code. For tables with more than 22 columns, slick-codegen does not generate a case class, but a HList-based custom type and a companion ‘constructor’ method. As I understand it, this is because the limitation that tuples and case classes can only have 22 fields. The way the code is generated, the

What does the <> operator do in Slick?

自作多情 提交于 2019-11-28 08:14:43
I was walking through the documentation of Slick to setup a quick working prototype. I was going through this link . In the Mapped Tables section I see a <> operator in the example mentioned but cant find any documentation for that anywhere. Need help in understanding this. Andreas Neumann The <> operator defines a relation between a Row in the Table and a case class . case class User(id: Option[Int], first: String, last: String) ROW |id | first | last | So the data first is taken out of the Tabels as an n-tuple (left side of <> ) and then transformed to the case class (right side of <> ). To