Skip to main content

Questions tagged [anorm]

Anorm is a simple data access layer included in the Play Framework. It uses plain SQL to interact with the database and provides an API to parse and transform the resulting datasets.

0 votes
1 answer
12 views

Is there a way to parse multiple case classes from a join

I have the following case classes representing entities: case class A(id: Long, name: String) case class B(id: Long, someField: String) val parser = Macro.namedParser[A] ~ Macro.namedParser[B] val ...
rvange's user avatar
  • 2,512
0 votes
1 answer
32 views

Comparing impact of Scala PlayFramework's db.withConnection and db.withTransaction methods on the underlying postgres database

Given that there is just one simple SQL statement (example: select id from foo) that I need to execute on my Postgres 15 database, I am curious to know the performance impact of executing it using ...
Prakhar Singh's user avatar
0 votes
0 answers
9 views

Proper way to handle SQL errors in anorm?

I see that executeQuery returns a SqlQueryResult, which has a statementWarning() that returns Option[SQLWarning]. Is this the only place I should check to see whether my insert failed? The doc ...
A_P's user avatar
  • 326
0 votes
0 answers
23 views

Anorm - load the records in a Vector instead of a list

Is there an easy way to load the records in a Vector[T] instead of a List[T]. All the examples that I can find on the docs return records in List objects. Thanks
boggy's user avatar
  • 3,941
0 votes
1 answer
172 views

Not able to connect to spark thrift server via jdbc driver in play framework with anorm

I am trying to connect my spark thrift server using play framework via anorm. Play framework version - 2.8.18 Connecting to jdbc as explained here Anorm - 2.7.0 Spark thrift server version - spark 3....
Bill Goldberg's user avatar
0 votes
1 answer
47 views

Pattern matching using regex with Scala Anorm

I'm Using Scala(2.11) and playframework(2.3) and trying to run a query using a helper function to get results through pattern matching. The function is as follows def resultsfunc() = { val ...
Maniyan's user avatar
  • 35
1 vote
1 answer
223 views

Scala List[Unit] to List[String] conversion

This is a pretty basic issue but I couldn't find a solution after spending an hour on it. I'm trying to query database to get a list of values through Scala Anorm ORM. I want to convert the result to ...
Maniyan's user avatar
  • 35
1 vote
1 answer
122 views

Anorm replacement of params gives error on usage of aggregate functions

Table structure - create table test (month integer, year integer, thresholds decimal(18,2) ); Static insert for simulation - insert into test(month,year,threshold) values(4,2021,100),(5,2021,98),(6,...
ForeverLearner's user avatar
0 votes
1 answer
71 views

Scala anorm running query to postgreSQL with set role command

I need to execute query in PostgreSQL using anorm. In order to handle authorization I have to set role along with query. My query is as follows. set role myuser; select country from country_list This ...
Bill Goldberg's user avatar
0 votes
0 answers
43 views

Parsing different queries with same parser anorm

I was trying to parse some different SQL queries using one anorm parser. Some of the queries will return a,b,c as their result. Eventually, one of the query will return a,b,c,d,e. The result is ...
Sachin verma's user avatar
0 votes
0 answers
87 views

Parameters are not getting replaced in Anorm prepared query for embedded text queries

We have a use-case where we need to pivot the result set of a query to columns for insert statement. For that, we are using crosstab which takes text sql as a parameter. so the query might ...
Alex A.'s user avatar
  • 2,557
0 votes
1 answer
106 views

Anorm with SQL expressions as parameter values

I am trying to create this SQL statement with Anorm in Scala. I am using a Postgres DB. insert into my_table (coords) values (ST_GeomFromText('POINT(26.9484 24.03937)',4326) I have tried this code: ...
David MacCallum's user avatar
0 votes
1 answer
62 views

Anorm - generic insert

Is there a way to use Anorm like a regular ORM? I'd like to have a method that just inserts an element provided. def insert[T](element: T)(implicit connection: Connection) = { element.insert(...
Dmitry  Meshkov's user avatar
1 vote
1 answer
104 views

Anorm (Scala) How to return Json from a joint table?

I'm trying to link 2 tables together and return json from it, unfortunatly the documentations and online are not very clear about this, so if you know how to solve this please provide a snippet that I ...
fosowe's user avatar
  • 61
1 vote
2 answers
589 views

How do I insert JSON into a postgres table using Anorm?

I'm getting a runtime exception when trying to insert a JSON string into a JSON column. The string I have looks like """{"Events": []}""", the table has a column defined as status JSONB NOT NULL. I ...
CPS's user avatar
  • 538

15 30 50 per page
1
2 3 4 5
25