slick

22 Column limit for procedures

可紊 提交于 2019-12-29 06:57:10
问题 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? 回答1:

How to catch slick postgres exceptions for duplicate key value violations

老子叫甜甜 提交于 2019-12-28 13:22:29
问题 My table has a unique index on a pair of columns in my postgresql database. I want to know how I can catch a duplicate key exception when I am inserting: def save(user: User)(implicit session: Session): User = { val newId = (users returning users.map(_id) += user user.copy(id = newId) } My logs show this exception: Execution exception[[PSQLException: ERROR: duplicate key value violates unique constraint "...." I haven't really used exceptions much in scala either yet also. 回答1: Your save

Why Playframework database configuration error in application.conf

霸气de小男生 提交于 2019-12-25 17:25:33
问题 I have have correct PostgreSQL installed and I can use this by other framework such as Spring. When I tried write some code for Play 2.1 that should use postgresql 9.4.1. I'm also using Slick 3.0. I have following in the application.conf db.default.driver="org.postgresql.Driver"
 db.default.url="jdbc:postgresql:mydb"
 db.default.user=myuser 
db.default.password=mypass When I start application it give error:- Missing configuration [db.ansiDump.driver] I added db.ansiDump.driver="org.postgresql

Slick PNGDecoder Error - java.lang.UnsupportedOperationException: Unsupported format for this image

时光毁灭记忆、已成空白 提交于 2019-12-25 17:14:42
问题 I'm making a simple little Galaga clone in Java with the Slick library. Unfortunately, I've run into an issue in which I get this error, followed by the game closing: Mon May 12 08:54:32 EDT 2014 WARN:class org.newdawn.slick.opengl.PNGImageData failed to read the data java.lang.UnsupportedOperationException: Unsupported format for this image at org.newdawn.slick.opengl.PNGDecoder.decode(PNGDecoder.java:272) at org.newdawn.slick.opengl.PNGImageData.loadImage(PNGImageData.java:97) at org

Groupby on multiple objects generates invalid SQL in slick

不羁的心 提交于 2019-12-25 16:25:57
问题 I am writing a query that calculates a possible score for a QuestionAnswer, when executing the query I get a PSQLException Info about the model A QuestionAnswer can have several (at least one) questionAnswerPossibilities, since there are multiple ways to answer the question correctly. Every questionAnswerPossibility has several questionAnswerParts, in the query below we query the score per questionAnswerPossibility. The Problematic Query The query itself does generate SQL, but the SQL can not

Groupby on multiple objects generates invalid SQL in slick

安稳与你 提交于 2019-12-25 16:25:26
问题 I am writing a query that calculates a possible score for a QuestionAnswer, when executing the query I get a PSQLException Info about the model A QuestionAnswer can have several (at least one) questionAnswerPossibilities, since there are multiple ways to answer the question correctly. Every questionAnswerPossibility has several questionAnswerParts, in the query below we query the score per questionAnswerPossibility. The Problematic Query The query itself does generate SQL, but the SQL can not

Slick 3.0.0 Mapping Existing Models

隐身守侯 提交于 2019-12-25 11:57:22
问题 I have a model that is composed of three case classes as below: case class MyModel(myId: MyIdType, name: MyNameType) case class MyIdType(id: Long) case class MyNameType(name: String) object MyNameType(name: String) { val NAME1 = MyNameType("name1") val NAME2 = MyNameType("name2") val NAME3 = MyNameType("name3") } Let's say these are the existing models. I have a Slick table mapping that goes like this: class MyTable(tag: Tag) extends Table[MyTableElem](tag, "myTable") { def id = column[Long](

Scala Slick 3 high query latency

自古美人都是妖i 提交于 2019-12-25 08:00:43
问题 I am running a very simple query using Slick. The actual database call, according to the logs, only takes ~500µs, but the time between my db.run call and the result is much higher (around 200ms) Please find below the code snippets that runs the query. It very naively prints timestamps before and after query execution ;) The predictions table is a very simple 4 columns table mapped to a case class. def getPredictionById(predictionId: Int) = { println(new Date().getTime()) val r = Await.result

Scala Slick delete not working

一世执手 提交于 2019-12-25 05:49:08
问题 when deleting from my tablequery object I should be able to write: FacebookAuths.delete But it's complaining that delete isn't a method in TableQuery, even if I try: Users.filter(_.id === 1337).delete It's still saying that delete isn't a method, but now on the Query object. What am I doing wrong? My imports are: import scala.slick.lifted._ import scala.slick.driver.JdbcDriver.simple._ And all other things like firstOption works. I use postgres. Thanks! 回答1: You are using Postgres , so you

Scala Slick 3.0 Creating Table and then Inserting Rows

折月煮酒 提交于 2019-12-25 04:33:38
问题 I have written this code to create a table and then insert few rows and print the number of rows inserted. package com.example import tables._ import scala.concurrent.{Future, Await} import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.duration.Duration import slick.backend.DatabasePublisher import slick.driver.H2Driver.api._ object Hello { def main(args: Array[String]): Unit = { val db = Database.forConfig("h2mem1") try { val people = TableQuery[Persons] val