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
14
votes
1 answer

Slick outer join with multiple tables

Doing an outer join between two tables is easy: tblA.leftJoin(tblB).on(_.aId === _.bId) But when doing joins between 5 tables it quickly becomes unwieldy: tblA.leftJoin(tblB).on(_.aId === _.bId). leftJoin(tblC).on(_._1.aId === _.cId). …
Martin Kolinek
  • 2,010
  • 14
  • 16
14
votes
2 answers

scala slick query return value

I am rather new at Scala and have been struggling with slick and can't see how to return the results of a query to the calling method I have a simple UserDto case class UserDto(val firstName:String, val lastName:String, val userName:String, …
Doug Anderson
  • 245
  • 1
  • 2
  • 10
13
votes
4 answers

Unknown data type "JSONB" when running tests in play slick with H2 Database

I have evolution problem Unknown data type: "JSONB" when running tests in playframework using playframework v2.6.6 for scala play-slick v3.0.2 play-slick-evolutions v3.0.2 postgresql - 42.0.0 h2database - 1.4.194 My H2DbConnector looks like…
Azik
  • 169
  • 1
  • 1
  • 10
13
votes
2 answers

How do compiled queries in slick actually work?

I am looking for a detailed explanation about the execution of compiled queries. I can't understand how they just compile once and the advantage behind their use
Im89
  • 139
  • 1
  • 10
13
votes
1 answer

Mapping Between Enumeration on Scala and Slick

I am newbie to Play Scala and Slick. I am trying to map between Enumeration on Scala to String/Int on Slick. I wrote the following code but I got an error. Could you please let me know how I can fix this. I am using Scala 2.11.6, Slick 3.1.0, Play…
Yohei Onishi
  • 1,362
  • 1
  • 19
  • 42
13
votes
2 answers

How to implement enums in scala slick 3?

This question has been asked and answered for slick 1 and 2, but the answers don't seem to be valid for slick 3. Attempting to use the pattern in How to use Enums in Scala Slick?, object MyEnumMapper { val string_enum_mapping:Map[String,MyEnum] =…
kbanman
  • 4,223
  • 6
  • 32
  • 40
13
votes
2 answers

What is the right way to work with slick's 3.0.0 streaming results and Postgresql?

I am trying to figure out how to work with slick streaming. I use slick 3.0.0 with postgres driver The situation is following: server have to give client sequences of data split into chunks limited by size(in bytes). So, I wrote following slick…
13
votes
1 answer

Why do I get "expected class or object definition" when defining a type in scala?

If I write something like this (to define Slick tables as per docs): type UserIdentity = (String, String) class UserIdentity(tag: Tag){ ... } I get a compile error: "expected class or object definition" pointing to the type declaration. Why?
gotch4
  • 13,093
  • 29
  • 107
  • 170
13
votes
3 answers

Custom mapping to nested case class structure in Slick (more than 22 columns)

I'm trying to map a DB row with more than 22 columns to a case class tree. I'd rather not using HList as I don't want to work with that API, and also for some exponential compilation time feedbacks that I've read somewhere... I have read this thread…
Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419
13
votes
1 answer

"Hello World" example for Slick 2.0 with MySQL

Is there an example of how to use the Slick 2.0.1 library for Scala to connect to a MySQL database? I could not find up-to-date examples with Googling... Recently, I have been thinking about porting the code for the web application that I have been…
Kotaro
  • 481
  • 2
  • 9
  • 19
13
votes
3 answers

Scala Slick Lazy Fetch

I want to be able to fetch all records from a very big table using Slick. If I try to do this through foreach, for or list fetching; I get an Out Of Memory Exception. Is there any way to use "cursors" with Slick or lazy loading that only fetch the…
Octavio Luna
  • 340
  • 4
  • 9
12
votes
2 answers

NullPointerException on executing concurrent queries using Slick

I am working on a Scala application with Postgres 9.3 and Slick 3.1.1. I am getting Null Pointer Exception on slick driver when multiple queries execute at the same time. Here is my simplified code. I am creating multiple actors which will call the…
Yadu Krishnan
  • 3,492
  • 5
  • 41
  • 80
12
votes
2 answers

Printing interpolated SQL query in Slick

I am trying to print an interpolated Slick2 SQL statement for debugging and all I get is the one with question marks e.g. def query(name: String) = sql"SELECT MAX(age) FROM users WHERE name = $name".as[Int] println(query("Bob").getStatement) The…
pathikrit
  • 32,469
  • 37
  • 142
  • 221
12
votes
1 answer

Using Slick with shapeless HList

Slick's support for HList is generally a great thing. Unfortunately, it comes with its own implementation that does barely provide any useful operations. I'd therefore like to use the shapeless HList instead. This is supposed to be "trivial", but I…
Taig
  • 6,718
  • 4
  • 44
  • 65
12
votes
1 answer

Configuring a Postgresql connection with Play 2 and Slick-Play

I'm learning how to build an application using Scala and the Play 2 Framemork. I`ve created a new project using the activator tool, based on "play-scala-intro" current template. The template have a sample app using the Play-Slick 1.0 for managing…
damorais
  • 135
  • 1
  • 8