Questions tagged [slick-2.0]

Slick is a modern database query and access library for Scala by Typesafe. Use this tag for specific issues with features introduced in 2.0. Otherwise use the generic [tag:slick]

Use this tag if your question describes issues with features introduced in 2.0 (January 2014).

Specific Features for 2.0 that might require this tag above the generic :

  • Code generator for reverse-engineering the database schema and code generation
  • Driver architecture to allow support for non-SQL, non-JDBC databases.
  • Syntax in the Lifted Embedding in Table definitions
  • Table definitions (and their * projections)
  • HList abstraction for records of arbitrary size
  • Soft inserts
  • The new model for pre-compiled queries
  • dynamicSession (replaced threadLocalSession)
  • server-side Option conversions
  • Changes to the API for Scala Collections syntax.
  • direct embedding (improved)
  • Query scheduling
  • The code generator phase
  • Full type information available in query ASTs

Adapted from the release notes

195 questions
7
votes
1 answer

Defining projection to map to nested case classes

I have these case classes: case class PolicyHolder(id : String, firstName : String, lastName : String) case class Policy(address : Future[Address], policyHolder : Future[PolicyHolder], created : RichDateTime, duration : RichDuration ) I then have…
Chris Stewart
  • 1,641
  • 2
  • 28
  • 60
7
votes
1 answer

Play Slick 2.1.0 This DBMS allows only a single AutoInc column to be returned from an INSERT

In the following code I can insert my records just fine. But I would really like to get back the ID of the inserted value so that I can then return the object as part of my response. def postEntry = DBAction { request => request.body.asJson.map…
Eric Goode
  • 156
  • 1
  • 5
7
votes
1 answer

Slick 2.0 Generic CRUD operations

I've been looking around on how to implement a generic trait for commons CRUD and other kinds of operations, I looked at this and this and the method specified are working well. What I would like to have is a generic method for insertion, my class…
Ende Neu
  • 15,581
  • 5
  • 57
  • 68
6
votes
2 answers

Slick nested outer joins with many-to-many tables

I'm stuck with a slick query and I unfortunately can't find a similar example. Config: scalaVersion := "2.11.7" libraryDependencies += "com.typesafe.play" %% "play-slick" % "2.1.0" Heres the scenario. I have a table/model that's called Record. The…
Nocebo
  • 1,927
  • 3
  • 15
  • 26
6
votes
1 answer

How to create projection class for complex case class in slick?

For example I have this case class: case class User( var identityId: IdentityId, //Its a user created class var firstName: String, var lastName: String, var fullName: String, var email: Option[String], var avatarUrl: Option[String], …
mane
  • 1,149
  • 16
  • 41
6
votes
1 answer

slick 2.0 define generic `find by field` method

import scala.slick.driver.MySQLDriver.simple._ class RichTable[T](tag: Tag, name: String) extends Table[T](tag, name) { case class QueryExt[B](q: Query[RichTable.this.type, B]) { def whereEq[C](col: RichTable.this.type => Column[C], c: C) =…
jilen
  • 5,633
  • 3
  • 35
  • 84
6
votes
1 answer

Sending writes to the mysql master and reads to slave in slick

With Slick and a Master/Slave set up with MySQL, how do I ensure writes (INSERT, UPDATE, etc) are sent to the master and reads (SELECT) are send to the slaves?
theon
  • 14,170
  • 5
  • 51
  • 74
5
votes
1 answer

Table creation in play 2.4 with play-slick 1.0

I got the play-slick module up and running and am also using evolution in order to create the required tables in the database during application start. For evolution to work it is required to write a 1.sql script which contains the table definitions…
evermean
  • 1,255
  • 21
  • 49
5
votes
2 answers

Slick error while compiling table definitions: could not find implicit value for parameter tm

I am completely new to Slick. I am trying to create a basic table type, but it just doesn't compile. Here's my code: import scala.slick.driver.PostgresDriver._ import scala.slick.lifted.Tag import scala.slick.lifted.Column import…
Midiparse
  • 4,701
  • 7
  • 28
  • 48
5
votes
1 answer

groupBy method throws an error in Slick

The codes looks like this: case class Supplier(snum: String, sname: String, status: Int, city: String) class Suppliers(tag: Tag) extends Table[Supplier](tag, "suppliers") { def snum = column[String]("snum") def sname = column[String]("sname") …
Hanfei Sun
  • 45,281
  • 39
  • 129
  • 237
5
votes
1 answer

Does Slick support methods 'inSet' or 'in' for tuples?

I'm using Slick 2.1.0 and PostgreSQL 9.x. How can I make this SQL (correct for postgresql) using Slick lifted query: select * from someObjects where (key, value) in (('k1', 'value1'), ('k2', 'value2')); This code is not works (can't…
John Mullins
  • 1,061
  • 4
  • 11
  • 38
5
votes
1 answer

Slick 2.0 Map a java.util.Date in a Table

I use slick 2.0 and I have a simple case class : case class Message(id: Option[Long], userId: Option[Long], body:String, creationDate:Date) And the following mapping : class Messages(tag: Tag) extends Table[Message](tag, "message") { import…
ACO
  • 295
  • 1
  • 3
  • 11
5
votes
1 answer

How to manually mapping String to postgresql text instead of just varchar(254)?

I use slick2+postgresql 9.3+playframework 2 My data model is: class Page(tag:Tag) extends Table[(Long,Long, String,String,String, Option[Long], Option[Long])](tag, "Page"){ def id=column[Long]("ID", O.PrimaryKey) def…
user504909
  • 9,119
  • 12
  • 60
  • 109
4
votes
0 answers

Slick-CodeGen for specific tables

I am looking at the slick 2.1 code generation utility (working with legacy code). http://slick.lightbend.com/doc/2.1.0/code-generation.html I don't see a syntax which will allow me to run the code-gen on only a few specific tables. So I added new…
Knows Not Much
  • 30,395
  • 60
  • 197
  • 373
4
votes
1 answer

How to query Slick with an optional foreign key to return all records with and without relationship?

I have an optional foreign key defined on Event which goes to EventType. I want to query for all events, even those events which have a None (null) event type. This is the foreign key defined on Event. def eventTypeId =…
Phil
  • 46,436
  • 33
  • 110
  • 175
1
2
3
12 13