Questions tagged [slick]

Slick acronym for Scala Language-Integrated Connection Kit, is a modern database query and access library for Scala by Lightbend.

Slick

Slick is a modern database query and access library for Scala. It allows you to work with stored data almost as if you were using Scala collections while at the same time giving you full control over when a database access happens and which data is transferred. You can write your database queries in Scala instead of SQL, thus profiting from the static checking, compile-time safety and compositionality of Scala. Slick features an extensible query compiler which can generate code for different backends.

Slick (Scala Language-Integrated Connection Kit) is Lightbend‘s Functional Relational Mapping (FRM) library for Scala that makes it easy to work with relational databases. It allows you to work with stored data almost as if you were using Scala collections while at the same time giving you full control over when a database access happens and which data is transferred. You can also use SQL directly. Execution of database actions is done asynchronously, making Slick a perfect fit for your reactive applications based on Play and Akka.

2469 questions
1
vote
2 answers

How to send results of a Scala StaticQuery SELECT query direct to JSON object

In Scala how can I most directly send the results of a MySql query to a JSON string? We're working within the "play" framework and are using "slick" to connect to MySQL, so I'm more specifically trying to results of a slick's StaticQuery SELECT…
mjhm
  • 16,497
  • 10
  • 44
  • 55
1
vote
0 answers

How Do I Use Slick When I Don't Know the Returned Types at Compile Time?

I'm using Slick but I can't define a type at compile time to hold the query result. Instead, the application requirements specify the columns to retrieve at runtime. I've tried an implicit like below, but when I run my test program (just a simple…
1
vote
0 answers

Play Framework: Cannot import generated sources (src_managed)?

I'm using this example https://github.com/slick/slick-codegen-example to generate sources based on my SQL schema. The generation finishes successfully but I'm unable to import them in my controller. Eclipse does not complain and is able to resolve…
aiman86
  • 71
  • 8
1
vote
1 answer

how to get the Joined foregin key object in slick?

I use playframework2+slick2.0 My datamodel: class Page(tag:Tag) extends Table[(Int,Int, String,String,String, Option[String], Option[String])](tag, "Page"){ def id=column[Int]("ID", O.PrimaryKey) def subId=column[Int]("subject") def…
user504909
  • 9,119
  • 12
  • 60
  • 109
1
vote
2 answers

Is there a working example of Slick 2.0 AutoInc with Postgres?

I am relatively new to Slick and I keep getting the org.postgresql.util.PSQLException: ERROR: null value in column "id" violates not-null constraint message. I found plenty of examples with Slick 1.x but none of them seem to work with Slick 2.0 Can…
Daghan ---
  • 1,147
  • 1
  • 9
  • 10
1
vote
1 answer

Trying to get slick working on a simple play2 app

I'm using IntelliJ 13, my build.sbt looks like: name := "hello" version := "1.0-SNAPSHOT" libraryDependencies ++= Seq( //"org.apache.tomcat" %% "tomcat-jdbc" % "8.0.5", "mysql" % "mysql-connector-java" % "5.1.30", "com.typesafe.slick" %%…
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
1
vote
2 answers

Slick library w/ Play - date type incompatibility?

I'm running into a compatibility problem under Scala while using Slick and Play. I'm attempting to use the Date type in one of my model schema via Slick, and then make that date available in a form in Play: Model: case class Test(id: Int, date:…
Shookit
  • 1,162
  • 2
  • 13
  • 29
1
vote
1 answer

Slick 2 fails to compile query which returns tuple

I'm now trying to make use of Slick's compiled queries feature. For simple queries it works fine, but queries involving joins with Tuple return type cause compilation error. Here's one of the dao methods I'm trying to rewrite with compiled queries:…
Jk1
  • 11,233
  • 9
  • 54
  • 64
1
vote
1 answer

type not inferred correclty in intellij

I am using slick's for expression, and seeing some strangeness in terms of intellij's inferred type. Here are the unexpected result: Why in the second case, it is not Query[Int, Int] but instead becomes Query[Nothing, Nothing]. I seem to lose some…
user2602930
1
vote
1 answer

Eclipse Scala IDE slow and crashes caused by Slick generated HCon (HList)

I'm using Eclipse 4.3.2 Scala IDE 3.0.3 and so far it's been fine. Lately however I've started using Slick 2.0.1 code generator and since there are some pretty heavy tables on my database (up to 200 columns), Slick code generator uses "HList…
Caballero
  • 11,546
  • 22
  • 103
  • 163
1
vote
1 answer

Why do I need to import driver to use lifted queries?

I'm using slick 2.0 for my interaction with the database. As recommended I've added external connection pool using BonesCP. val driver = Class.forName(Database.driver) val ds = new BoneCPDataSource(); ds.setJdbcUrl(Database.jdbcUri); …
almendar
  • 1,823
  • 13
  • 23
1
vote
1 answer

Slick 2 generator: tables with same names on different schemas

I'm using Slick 2 code generator and so far so good, but there is one problem though. If I have 2 schemas on my Postgres database and each of those schemas have a table with the same name - code generator creates duplicate classes resulting in an…
Caballero
  • 11,546
  • 22
  • 103
  • 163
1
vote
1 answer

Send Akka messages with database update

I am trying to implement a method in scala that performs couple of database updates using Slick (in the same DB transaction) and then sends several akka messages. Both sending messages and db updates should be atomic. In JEE world it happens pretty…
andruha
  • 65
  • 7
1
vote
1 answer

What is the best way to go about referencing multiple tables using slick 2.0?

I have these tables: USERS, USER_ROLES, ROLES, PERMISSIONS, ROLE_PERMISSIONS I am implementing the: AssignedRoles (M): returns the set of roles assigned to a given user; So, if I was going to write the query for this function it would like…
James Little
  • 601
  • 7
  • 24
1
vote
1 answer

Factoring case class attributes, any way around the limitations on case class extention?

I would like to factor some common attributes of my case classes, say an id and a timestamp, to write generic code these. The following works fine, but I have to repeat all attributes on each case class: trait HasIdAndTimestamp { val id: Int val…
OlivierBlanvillain
  • 7,701
  • 4
  • 32
  • 51