Questions tagged [scalikejdbc]

ScalikeJDBC is a tidy SQL-based DB access library for Scala developers. This library naturally wraps JDBC APIs and provides you easy-to-use and very flexible APIs.

97 questions
2
votes
1 answer

ScalikeJDBC won't connect to NamedDB for DSL queries in ScalaTest test cases

I'm having a heck of a time using a test database for my ScalaTest test cases, as shown in the documentation examples. I have a default database, and a testdb database, and my Spec looks like class JobSpec extends FlatSpec with AutoRollback { …
Josh Lemer
  • 446
  • 3
  • 18
2
votes
1 answer

ScalikeJdbc Multiple Insert

How do we perform multiple inserts in the same transaction? def insertData(dataList: List[Data])(implicit session: DBSession = autoSession) = { // todo: this is probably opening and closing a connection every time? dataList.foreach(data…
BAR
  • 15,909
  • 27
  • 97
  • 185
2
votes
1 answer

Join on two foreign keys from same table in scalikejdbc

So i have a one table that has two FK that points at same table. For example: Message table with columns sender and receiver that both references id in user table. When i'm writing query to fetch message and join on both the result is same use for…
Gustek
  • 3,680
  • 2
  • 22
  • 36
2
votes
2 answers

Scalikejdbc query results as a stream

For very large datasets, is it possible to return the results of a scalikejdbc query as a Stream? i.e. where the cursor stays open until the Stream has been exhausted so as to save on memory use? If so, how?
Synesso
  • 37,610
  • 35
  • 136
  • 207
1
vote
1 answer

scalikejdbc and MySQL subquery WHERE IN (SELECT statement)

It looks like scalikejdbc doesn't support MySQL's WHERE IN (SELECT statement) queries, as IN requires a sequence of items as a parameter, it doesn't accept a query. Any ideas for making it work? Thank you!
synthetic
  • 798
  • 1
  • 7
  • 20
1
vote
0 answers

There are no objects available and the waitQueue is full, scalikejdbc

Objective I want to update(replace) list of data in database. Note - When i run on list of size 10 there is no error. But when i run more than 10 i get below error. Sometime if run different repository similar code then i face same error. Error…
1
vote
0 answers

Concat conditions to existing query in ScalikeJDBC

I am using ScalikeJDBC in my project and I have an SQL query like this val str = "select name, age from employee" val selectQueryString = sqls"$str" val like = "%" + term + "%" val emp: List[Employee] = db.localTx { implicit session…
user9920500
  • 606
  • 7
  • 21
1
vote
0 answers

ScalikeJDBC How can sort query by aggregate function?

my project have next tables: Posts, Users, comments. Post one-to-many comments, Post many-to-one users. I want to get All posts with comments and user and order by comments count. First problem was uncorrect limit, but I fixed this by sub-queries.…
evfenyt
  • 21
  • 1
1
vote
0 answers

How to incorporate custom types with the auto-generated case class / companion object files?

I'm building an application with alayered architecture pattern, specifically controller -> service -> repository, in which the repository layer ideally performs the database transactions and returns it back up the chain. I also have a models package…
maxwellmattryan
  • 113
  • 1
  • 9
1
vote
0 answers

Steaming data from postgres byteEA type column via ScalikeJDBC

What methodes are available to stream the result of a byteEA column from a postgres database via ScalikeJDBC. My question is not about streaming results e.g a query has 1 000 000 results and results are streamed to the application BUT about…
Th 00 mÄ s
  • 3,776
  • 1
  • 27
  • 46
1
vote
0 answers

Inserting (and NOT upserting) using scalikejdbc

I do not see a way to execute my sql insert statement without using scalikejdbc's update or execute functions, both of which turn my insert into an upsert. sql"""INSERT INTO scopes (id, name, status, level) VALUES ($id, $name, $status,…
naomie
  • 11
  • 1
1
vote
0 answers

ScalikeJDBC: How to do select or insert query aginst a Postgresql db?

I have the following SQL code I would to execute against a Postgresql db: sql"""WITH s AS ( SELECT id FROM $tableName WHERE $columnName = $value ), i AS ( INSERT INTO $tableName…
zaxme
  • 1,065
  • 11
  • 29
1
vote
1 answer

SQL interpolation with ScalikeJDBC

I try to reproduce the example of SQL interpolation with the library ScalikeJDBC (here). val member = sql"select id, name from members where id = ${id}" println(member.statement) But I get a weird result : select id, name from members where id =…
Thomas
  • 1,164
  • 13
  • 41
1
vote
1 answer

Simple select with max using scalike jdbc

Still trying to get familiar with scalikejdbc. What is the simplest way to just use sql syntax to send a query using scalike jdbc into a table to get max date? Something really simple like the below works fine but gives me an error when I try to add…
horatio1701d
  • 8,809
  • 14
  • 48
  • 77
1
vote
0 answers

Listing ScalikeJDBC results returning only one result

I am attempting to retrieve a list of user IDs from a database in Scala using ScalikeJDBC. My issue is that the query, when I run it in a database tool, returns many rows. However, when I attempt to retrieve this data as a list in Scala, it…
Brian Risk
  • 1,244
  • 13
  • 23