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

Why doesn't ScalaQuery create ddl for foreign key?

I have the following table definitions using ScalaQuery 0.10.0-M1: import org.scalaquery.ql.basic.{ BasicTable => Table } object Nodes extends Table[(String, String)]("node") { def id = column[String]("id", O.PrimaryKey) def name =…
Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
2
votes
2 answers

Re-using sessions in ScalaQuery?

I need to do small (but frequent) operations on my database, from one of my api methods. When I try wrapping them into "withSession" each time, I get terrible performance. db withSession { SomeTable.insert(a,b) } Running the above example 100…
Rogach
  • 26,050
  • 21
  • 93
  • 172
2
votes
2 answers

Why "Missing parameter type" when accessing a table in a "withTransaction" clause in ScalaQuery?

This code: def insAll(values: MyRdt*) { Db.withTransaction(session => { // Db is an org.scalaquery.session.Database instance MyTable.insertAll(values: _*)(session) }) } doesn't compile. The error is ... missing parameter type [error] …
Ivan
  • 63,011
  • 101
  • 250
  • 382
1
vote
1 answer

scalaquery : Dynamic BatchInsert

The FirstExample in scalaquery-examples project provides an example of batch insert with the following Syntax: Coffees.insertAll( ("Colombian", 101, 7.99, 0, 0), ("French_Roast",49, 8.99, 0, 0), ("Espresso",150, 9.99, 0, 0), …
krishnen
  • 172
  • 1
  • 1
  • 9
1
vote
1 answer

Where is the implicit conversion from Query to UnitInvoker comming from?

In these examples ( https://github.com/szeiger/scala-query/wiki/Queries) foreach (via for comprehension) is used on a scalaquery Query. But foreach doesn't seem to be present in Query, but only in UnitInvoker. Where is the implicit conversion…
Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
1
vote
1 answer

How to insert autoincremented master/slave records using ScalaQuery?

Classic issue, new framework -- thus problem. PostgreSQL + Scala + ScalaQuery. I have Master table with serial (autincrement) id and Slave table also with serial id. I need to insert one master record and several slaves. I have to do it within…
greenoldman
  • 16,895
  • 26
  • 119
  • 185
1
vote
1 answer

scalaquery conversion

I have a query which gives a result as org.scalaquery.ql.Query[(java.lang.String, Int, java.lang.String)] What I need to do is to convert above query to a data list as follows List[(String,Int,String)] please give me a way to do this conversion…
tiran
  • 2,389
  • 1
  • 16
  • 28
1
vote
1 answer

scalaquery retrieve values

I have few tables, lets say 2 for simplicity. I can create them in this way, ... val tableA = new Table[(Int,Int)]("tableA"){ def a = column[Int]("a") def b = column[Int]("b") } val tableB = new Table[(Int,Int)]("tableB"){ def a =…
tiran
  • 2,389
  • 1
  • 16
  • 28
1
vote
1 answer

ScalaQuery's query/queryNA several times slower than JDBC?

In the following performance tests of many queries, this timed JDBC code takes 500-600ms: val ids = queryNA[String]("select id from account limit 1000").list val stmt = session.conn.prepareStatement("select * from account where id = ?") …
Yang
  • 16,037
  • 15
  • 100
  • 142
1
vote
1 answer

Supertype for scalaquery query

What is the supertype for all Scalaquery queries? As far as i have understood, Query[Projection[Product]] should be it, e.g.: Projection2[Int, Int] <: Projection[Tuple2[Int,Int]] <: Projection[Product] so val query: Query[Projection[Product]] =…
flying sheep
  • 8,475
  • 5
  • 56
  • 73
1
vote
0 answers

Slick Transaction commited , but not saved in table [Mysql]

I am trying to execute multiple DB actions in the same session. DEBUG logs show transaction Commit, But data not persistent on DB. I am using slick 3.2.3 with Scala Play framework 2.6. How can I resolve this issue. val d = (for { dir:…
1
vote
0 answers

Left Join with scalaquery on sqlite

I'm using scalaquery on a sqlite database (with the zentus jdbc driver), but when I select with a left join, I got the following Exception : Caused by: java.sql.SQLException: unrecognized token: "{" at org.sqlite.DB.throwex(DB.java:288) at…
Mr_Qqn
  • 1,578
  • 2
  • 13
  • 17
1
vote
0 answers

Slick 3. For Comprehension on query. Can I force to have Option

When I run next Query, I get nothing sometimes. This hapens when no associated breeder founded for my flower sort. for { sort <- flowerSorts if sort.id === flowerSortId sortDetails <- flowersSortDetails if sortDetails.id === flowerSortId …
1
vote
1 answer

slick schema leftJoin produce Cartesian product

I have this two tables : select * from "DEPARTMENTS"; ID | NAME | MANAGER_ID ----+-------+------------ 1 | FOO | 1 3 | XXX | 2 4 | dept1 | (3 rows) select * from "EMPLOYEES"; NAME | LAST | EMAIL …
igx
  • 4,101
  • 11
  • 43
  • 88
1
vote
2 answers

Slick 3.0 - Update columns in a table and return whole table object?

Here is the implementation for Slick 2. Slick 2 - Update columns in a table and return whole table object Does anyone have ideas about how to implement this in Slick 3?
Hanfei Sun
  • 45,281
  • 39
  • 129
  • 237