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.

Anorm, simple SQL data access layer for Scala and the Play Framework

The Play framework includes a simple data access layer called Anorm that uses plain SQL to interact with the database and provides an API to parse and transform the resulting datasets. Anorm is not an Object Relational mapper.

367 questions
55
votes
2 answers

NodeJS vs Play Framework for large project

I am really torn between two different stacks with which to build a large application. One the one hand there is this option: Node.js express coffee script coffeekup mongoose/mongodb or presistencejs/mysql Play Framework w/ Scala Anorm w/…
Jason Miesionczek
  • 13,718
  • 14
  • 73
  • 108
37
votes
4 answers

Where to see the logged sql statements in play2?

I found there is such a configuration in application.conf: # If enabled, log SQL statements being executed. db.default.logStatements=true I've enabled it, but I can't find any log file which logged executed sqls. Where can I find it, or do I miss…
Freewind
  • 177,284
  • 143
  • 381
  • 649
26
votes
7 answers

"In" clause in anorm?

It seems no easy way to use "in" clause in anorm: val ids = List("111", "222", "333") val users = SQL("select * from users where id in ({ids})").on('ids-> ???).as(parser *) How to replace the ??? part? I tried: on('ids -> ids) on('ids ->…
Freewind
  • 177,284
  • 143
  • 381
  • 649
23
votes
1 answer

Does Scala Anorm String Replacement Sanitize Inputs?

I am using the Play! framework along with Anorm to access the database. I often see examples like the following where object members are injected into the SQL statement directly. My question is, are these inputs sanitized? Most examples look like…
Jacob Groundwater
  • 6,221
  • 1
  • 25
  • 40
18
votes
1 answer

How to Retrieve the Primary Key When Saving a New Object in Anorm

I'm using Scala Play! framework with Anorm to persist the data model to the database. I followed the example code here : case class Bar(id: Pk[Long], name: String) object Bar { val simple = { get[Pk[Long]]("id") ~ get[String]("name") map…
Jacob Groundwater
  • 6,221
  • 1
  • 25
  • 40
16
votes
1 answer

Play2's anorm can't work on postgresql

I found that the row parsers of play2's anorm depend on the meta data returned by jdbc driver. So in the built-in sample "zentasks" provided by play, I can find such code: object Project { val simple = { get[Pk[Long]]("project.id") ~ …
Freewind
  • 177,284
  • 143
  • 381
  • 649
15
votes
1 answer

What is purpose of anorm's Pk?

I'm writing Playframework 2.0 application using Scala and Anorm to access db. Currently I'm using Pk[Long] for id fields and I'm worry about additional get call needed to access actual value. So I start using plain Long for id fields and everything…
lambdas
  • 3,818
  • 2
  • 25
  • 52
14
votes
3 answers

Dynamic SQL Parameters with Anorm and Scala Play Framework

Is it possible to dynamically create a list for anorm's "on" method? I have a form with optional inputs and currently I check each Option and create a list with the defined Options and am trying to pass this through to anorm. Currently I get this…
damian
  • 1,399
  • 1
  • 24
  • 38
13
votes
2 answers

What does the tilde (~) mean in this Scala example?

http://woss.name/2012/04/02/retrieving-bigdecimals-from-a-database-with-anorm-scala/ object Site { val allFieldsParser = { get[Pk[Long]]("sites.id") ~ // Help me parse this syntax get[String]("sites.name") ~ …
ripper234
  • 202,011
  • 255
  • 600
  • 878
13
votes
3 answers

anorm dynamic filters

I'm studying a little the anorm documentation (from play framework) and is not clear if it supports a common query use case: dynamic filters, that is the user fills in 2 or 3 search criteria on a 10 fields search form. In this case how can I…
dcernahoschi
  • 13,894
  • 5
  • 31
  • 55
12
votes
2 answers

Play scala advice on anorm vs slick

I am thinking of learning and using the play framework with scala for building web apps. However, I would like real advice on choosing between anorm and slick. My reservation for slick is the following: Will it remain free? Note: Quote from the…
zulqarnain
  • 1,572
  • 1
  • 13
  • 32
12
votes
2 answers

Is there a tool to automatically generate Anorm parser combinators?

I'm just getting started with Anorm and parser combinators. It seems like there is an awful lot of boilerplate code. For example, I have case class Model( id:Int, field1:String, field2:Int, // a bunch of fields omitted ) val…
bwbecker
  • 939
  • 7
  • 17
12
votes
1 answer

Anorm parse float values

In Play framework 2.0, I'm trying to load a real (i.e. single precision float) type column from PostgreSQL using a row parser like this: case class Foo(bar: Float) object Foo { def all = DB.withConnection { implicit c => SQL("SELECT *…
Stef Sijben
  • 153
  • 1
  • 8
12
votes
2 answers

Scala Play! Using anorm or ORM

It seems that all the sample applications provided by the Play! framework make use of anorm for persistence. What is the reason for choosing anorm over an ORM? If you are using an ORM, what are you using and why?
Brent Lemons
  • 133
  • 2
  • 6
10
votes
2 answers

DB Plugin is not registered in Play 2.0

I just started working with play, and I modified the way I'm doing a SQL read and I'm now getting the following error: [Exception: DB plugin is not registered.] The code I have for this class is: package models import play.api.db._ import…
PlexQ
  • 3,080
  • 2
  • 19
  • 24
1
2 3
24 25