anorm

Anorm's Row object no longer exists in Play 2.3

≡放荡痞女 提交于 2019-12-02 09:12:45
问题 After upgrading to Play 2.3.0 I get this compilation error on object Row not found: value Row I noticed the Row object no longer exists in play 2.3.0 (I've found only the Row trait). Looking at the documentation, pattern matching should be still supported in Play 2.3 http://www.playframework.com/documentation/2.3.x/ScalaAnorm See "Using Pattern Matching" paragraph Here's my code: def findById(aId: Long) = { DB.withConnection { implicit conn => SQL(byIdStmt).on("id" -> aId)().map { case Row(id

Migrating to anorm2.4 (with play 2.4): ToStatement[T] and ToStatement[Option[T]]

孤人 提交于 2019-12-02 05:01:48
问题 Up until the anorm included with play 2.3, I could write the following: implicit val arbitraryClassToStatement = new ToStatement[ArbitraryClass] { def set( s: java.sql.PreparedStatement, index: Int, aValue: ArbitraryClass ) : Unit = { s.setString( index, ArbitraryClass.definingString ) } } and this would help insert the SQL("INSERT INTO SomeTable Values( {nonNullAc}, {possiblyNullAc} )" ).on( 'nonNullAc -> ArbitraryClass( "abcd" ), 'possiblyNullAc -> Option( ArbitraryClass( "abcd" ) ) )

Migrating to anorm2.4 (with play 2.4): ToStatement[T] and ToStatement[Option[T]]

こ雲淡風輕ζ 提交于 2019-12-02 02:28:13
Up until the anorm included with play 2.3, I could write the following: implicit val arbitraryClassToStatement = new ToStatement[ArbitraryClass] { def set( s: java.sql.PreparedStatement, index: Int, aValue: ArbitraryClass ) : Unit = { s.setString( index, ArbitraryClass.definingString ) } } and this would help insert the SQL("INSERT INTO SomeTable Values( {nonNullAc}, {possiblyNullAc} )" ).on( 'nonNullAc -> ArbitraryClass( "abcd" ), 'possiblyNullAc -> Option( ArbitraryClass( "abcd" ) ) ) meaning that both ArbitraryClass and Option[ ArbitraryClass ] would be satisfied by it. This seems to no

Is there an easy way to get a Stream as output of a RowParser?

和自甴很熟 提交于 2019-12-01 23:10:38
Given rowParser of type RowParser[Photo] , this is how you would parse a list of rows coming from a table photo , according to the code samples I have seen so far: def getPhotos(album: Album): List[Photo] = DB.withConnection { implicit c => SQL("select * from photo where album = {album}").on( 'album -> album.id ).as(rowParser *) } Where the * operator creates a parser of type ResultSetParser[List[Photo]] . Now, I was wondering if it was equally possible to get a parser that yields a Stream (thinking that being more lazy is always better), but I only came up with this: def getPhotos(album:

DB Plugin is not registered in Play 2.0

走远了吗. 提交于 2019-12-01 16:37:17
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 play.api.Play.current import anorm._ case class Housing(id: Long, rent: String, address: String, street0: String, street1: String, neighbourhood: String) object Housing { def all(): List[Housing] = DB.withConnection { implicit c => SQL("select * from housing")().map { row => Housing(row[Long]("id"), row[String]("rent"), row[String]("address"), row[String](

How to enable trace/debugging output with Anorm on Play 2.4.0

半腔热情 提交于 2019-12-01 08:22:14
With Play 2.4.0 Anorm got moved to an external package and logging got changed to LogBack ( http://logback.qos.ch ) All well and good but nowhere are the class/package names obvious for tracing SQL calls. The "obvious" (based on the import statements) <logger name="anorm" level="TRACE" /> did nothing and I also tried <logger name="anorm.SQL" level="TRACE" /> just in case it needed to be more specific. Google searches just dead needed so I'm at a loss. Anyone? You can intercept calls going thru JDBC driver using log4jdbc I have used successfully with JPA/hibernate and Hikary on Play 2.4, the

How to declare dependency on Play's Anorm for a standalone application?

你。 提交于 2019-12-01 04:12:48
What is the current sbt syntax for using a recent version (say, 2.3 or 2.4) of Play's anorm package in standalone mode (not part of a Play application)? Anorm is now published as follows with no need for an additional resolver. "org.playframework.anorm" %% "anorm" % "2.6.2" In build.sbt : resolvers ++= Seq( "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/") libraryDependencies ++= Seq( "com.typesafe.play" %% "anorm" % "2.3.6") See example . 来源: https://stackoverflow.com/questions/25532080/how-to-declare-dependency-on-plays-anorm-for-a-standalone-application

How to declare dependency on Play's Anorm for a standalone application?

陌路散爱 提交于 2019-12-01 00:54:45
问题 What is the current sbt syntax for using a recent version (say, 2.3 or 2.4) of Play's anorm package in standalone mode (not part of a Play application)? 回答1: Anorm is now published as follows with no need for an additional resolver. "org.playframework.anorm" %% "anorm" % "2.6.2" 回答2: In build.sbt : resolvers ++= Seq( "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/") libraryDependencies ++= Seq( "com.typesafe.play" %% "anorm" % "2.3.6") See example. 来源: https:/

Batch insert with table that has many columns using Anorm

耗尽温柔 提交于 2019-11-30 18:09:15
问题 I'm trying to do a batch insert into a MySQL database table using Anorm (in the play framework 2.3.1). The application I'm building has a standard web front end in addition to requiring batch data inserts and I would like to try and keep the logic on the same software stack. The inserts only go into the same few tables. The number of rows to be insert at once will reach hundreds and may get into thousands, I expect I may need to limit the number of inserted rows at some point due to anorm /

anorm dynamic filters

只谈情不闲聊 提交于 2019-11-30 17:38:23
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 dynamically construct the query without the classic string manipulation? Yes, I think the question referenced by Robin Green contains the answer. Just define your query with all the possible criteria using placeholders (e.g. {criterion1} ) and call the on() method on the query, passing the actual Seq of Option parameters as described in the accepted answer