Questions tagged [scalaquery]

ScalaQuery is a typesafe API / DSL (domain specific language) built on top of JDBC for accessing relational databases in Scala.

The low-level JDBC API is powerful but comes with a lot of verbosity. ScalaQuery was designed from the ground up to reduce the amount of boilerplate required and make use of Scala's features to provide a more natural fit for database access in a Scala environment.

The basic idea is that tables in the database get represented as objects extending a Table trait. This object can then be used in for comprehension extremely similar to normal Scala collection.

ScalaQuery is not an ORM, i.e. it doesn't do caching, tracking of objects for change or similar things. It is more a way to replace or generate SQL.

NOTE: Since early 2012, ScalaQuery has evolved into Slick.

99 questions
89
votes
2 answers

scala slick method I can not understand so far

I try to understand some Slick works and what it requires. Here it an example: package models case class Bar(id: Option[Int] = None, name: String) object Bars extends Table[Bar]("bar") { def id = column[Int]("id", O.PrimaryKey, O.AutoInc) //…
ses
  • 13,174
  • 31
  • 123
  • 226
33
votes
3 answers

How to use SQL "LIKE" operator in SLICK

Maybe a silly question. But I have not found an answer so far. So how do you represent the SQL's "LIKE" operator in SLICK?
wassertim
  • 3,116
  • 2
  • 24
  • 39
27
votes
1 answer

How to make aggregations with slick

I want to force slick to create queries like select max(price) from coffees where ... But slick's documentation doesn't help val q = Coffees.map(_.price) //this is query Query[Coffees.type, ...] val q1 = q.min // this is…
Jeriho
  • 7,129
  • 9
  • 41
  • 57
22
votes
2 answers

How do I abstract the domain layer from the persistence layer in Scala

UPDATE: I've edited the title and added this text to better explain what I'm trying to achieve: I'm trying to create a new application from the ground up, but don't want the business layer to know about the persistence layer, in the same way one…
Jack
  • 16,506
  • 19
  • 100
  • 167
19
votes
0 answers

Which project is more mature, ScalaQuery or Squeryl?

For me both of them looks quite similar if it's going to features, but it's hard to say without using them (yet). So I have few questions: 1) Are they really feature comparable (more or less)? 2) Is there any example of enterprise or big open…
Piotr Kukielka
  • 3,792
  • 3
  • 32
  • 40
16
votes
1 answer

Slick and filtering by Option columns

I'm trying to filter against an optional date column with Scala Slick 1.0.1. It may be I just don't see it, but I've got a table that looks something like this: case class UserRole(id:UUID, userID:UUID, role:String) object UserRole extends…
Michael Kohout
  • 1,073
  • 1
  • 14
  • 26
16
votes
1 answer

How can I present a many-to-many relationship using a link table with ScalaQuery or SLICK?

I've asked a similar question recently, and got a great reply on solving a many-to-many relationship problem with Lift Mapper. I looked at the ScalaQuery/SLICK documentation but it does not document an approach to persisting data where link tables…
Jack
  • 16,506
  • 19
  • 100
  • 167
16
votes
2 answers

Play framework + SLICK (Scalaquery) tutorial

Does anybody know of a good tutorial or a sample project (github) of using Play framework with SLICK (ScalaQuery)? I am struggling to make them work together. I am getting this error: [info] play - Application started (Dev) [error] application - !…
Salil
  • 9,534
  • 9
  • 42
  • 56
13
votes
1 answer

Are there plans to support "type providers" for Scala's SIQ (ScalaIntegratedQuery) like in F#?

The current state of SIQ was presented by Christopher Vogt at ScalaDays 2011. It was shown how queries would work and look like, but as far as I remember there was no notion about how those types would be represented, e. g. if it is still necessary…
soc
  • 27,983
  • 20
  • 111
  • 215
13
votes
1 answer

How can I compose queries in ScalaQuery in order to create reusable traits?

I'm having some trouble composing different query components into a single Query. My goal is to create a set of traits (e.g. SoftDeletable, HasName, SortedByName, WithTimestamps) that I can simply mix-in to Table objects to add that behavior. The…
Bill
  • 44,502
  • 24
  • 122
  • 213
12
votes
5 answers

Scala collection-like SQL support as in LINQ

As far as I understand the only thing LINQ supports, which Scala currently doesn't with its collection library, is the integration with a SQL Database. As far as I understand LINQ can "accumulate" various operations and can give "the whole"…
soc
  • 27,983
  • 20
  • 111
  • 215
12
votes
5 answers

Select single row based on Id in Slick

I want to query a single row from user based on Id. I have following dummy code case class User( id: Option[Int], name: String } object Users extends Table[User]("user") { def id = column[Int]("id", O.PrimaryKey, O.AutoInc) def name =…
Khalid Saifullah
  • 747
  • 2
  • 8
  • 21
12
votes
1 answer

Select rows based on MAX values of a column in ScalaQuery/SLICK

Say that i have table such as: UserActions UserId INT ActionDate TIMESTAMP Description TEXT that holds dates where users perfomed certainActions. If i wanted to get the last action that every user perfomed, i would have to do something…
Angel Blanco
  • 681
  • 7
  • 18
11
votes
1 answer

How to do a paged query using ScalaQuery?

I have a query that returns Person objects that I’m using to fetch one page of results from the database: def page(pageNumber:Int, pageSize:Int) : Seq[Person] = database.withSession { val query = for(person <- People) yield person.mapped val…
Peter Hilton
  • 17,211
  • 6
  • 50
  • 75
11
votes
1 answer

SLICK 3.0 - multiple queries depending on one another - db.run(action)

I am new to Slick 3 and so far I have understood that db.run are asynchronous call. the .map or .flatMap is run once the Future is returned. The problem in my code below is that all the sub queries do not work (nested db.run). Conceptually speaking,…
user1237981
  • 165
  • 1
  • 8
1
2 3 4 5 6 7