anorm

SimpleSql

case class SimpleSql[T](sql: SqlQuery, params: Map[String, ParameterValue], defaultParser: RowParser[T]) extends Sql with Product with Serializable

Simple/plain SQL.

Source
Anorm.scala
Linear Supertypes
Serializable, Serializable, Product, Equals, Sql, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. SimpleSql
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. Sql
  7. AnyRef
  8. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new SimpleSql(sql: SqlQuery, params: Map[String, ParameterValue], defaultParser: RowParser[T])

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def as[T](parser: ResultSetParser[T])(implicit connection: Connection): T

    Executes this statement as query and convert result as T, using parser.

    Executes this statement as query and convert result as T, using parser.

    Definition Classes
    Sql
  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. val defaultParser: RowParser[T]

  10. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  11. def execute()(implicit connection: Connection): Boolean

    Executes this SQL statement.

    Executes this SQL statement.

    returns

    true if resultset was returned from execution (statement is query), or false if it executed update.

    val res: Boolean =
    SQL"""INSERT INTO Test(a, b) VALUES(${"A"}, ${"B"}""".execute()
    Definition Classes
    Sql
  12. def executeInsert[A](generatedKeysParser: ResultSetParser[A] = SqlParser.scalar[Long].singleOpt)(implicit connection: Connection): A

    Executes this SQL as an insert statement.

    Executes this SQL as an insert statement.

    generatedKeysParser

    Parser for generated key (default: scalar long)

    returns

    Parsed generated keys

    import anorm.SqlParser.scalar
    
    val keys1 = SQL("INSERT INTO Test(x) VALUES ({x})").
      on("x" -> "y").executeInsert()
    
    val keys2 = SQL("INSERT INTO Test(x) VALUES ({x})").
      on("x" -> "y").executeInsert(scalar[String].singleOpt)
    // ... generated string key
    Definition Classes
    Sql
  13. def executeQuery()(implicit connection: Connection): SqlQueryResult

    Executes this SQL query, and returns its result.

    Executes this SQL query, and returns its result.

    implicit val conn: Connection = openConnection
    val res: SqlQueryResult =
      SQL("SELECT text_col FROM table WHERE id = {code}").
      on("code" -> code).executeQuery()
    // Check execution context; e.g. res.statementWarning
    val str = res as scalar[String].single // going with row parsing
    Definition Classes
    Sql
  14. def executeUpdate()(implicit connection: Connection): Int

    Executes this SQL as an update statement.

    Executes this SQL as an update statement.

    returns

    Count of updated row(s)

    Definition Classes
    Sql
    Annotations
    @throws( "If statement is query not update" )
  15. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  16. def fold[T](z: ⇒ T)(op: (T, Row) ⇒ T)(implicit connection: Connection): Either[List[Throwable], T]

    Aggregates over all rows using the specified operator.

    Aggregates over all rows using the specified operator.

    z

    the start value

    op

    Aggregate operator

    returns

    Either list of failures at left, or aggregated value

    Definition Classes
    Sql
    See also

    #withIterator

    #foldWhile

  17. def foldWhile[T](z: ⇒ T)(op: (T, Row) ⇒ (T, Boolean))(implicit connection: Connection): Either[List[Throwable], T]

    Aggregates over part of or the while row stream, using the specified operator.

    Aggregates over part of or the while row stream, using the specified operator.

    z

    the start value

    op

    Aggregate operator. Returns aggregated value along with true if aggregation must process next value, or false to stop with current value.

    returns

    Either list of failures at left, or aggregated value

    Definition Classes
    Sql
    See also

    #withIterator

  18. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  19. def getFilledStatement(connection: Connection, getGeneratedKeys: Boolean = false): PreparedStatement

    Definition Classes
    SimpleSql → Sql
  20. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  21. def list()(implicit connection: Connection): Seq[T]

  22. def map[A](f: (T) ⇒ A): SimpleSql[A]

  23. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  24. final def notify(): Unit

    Definition Classes
    AnyRef
  25. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  26. def on(args: NamedParameter*): SimpleSql[T]

    Returns query prepared with named parameters.

    Returns query prepared with named parameters.

    import anorm.toParameterValue
    
    val baseSql = SQL("SELECT * FROM table WHERE id = {id}") // one named param
    val preparedSql = baseSql.withParams("id" -> "value")
  27. def onParams(args: ParameterValue*): SimpleSql[T]

    Returns query prepared with parameters using initial order of placeholder in statement.

    Returns query prepared with parameters using initial order of placeholder in statement.

    import anorm.toParameterValue
    
    val baseSql =
      SQL("SELECT * FROM table WHERE name = {name} AND lang = {lang}")
    
    val preparedSql = baseSql.onParams("1st", "2nd")
    // 1st param = name, 2nd param = lang
  28. val params: Map[String, ParameterValue]

  29. def single()(implicit connection: Connection): T

  30. def singleOpt()(implicit connection: Connection): Option[T]

  31. val sql: SqlQuery

  32. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  33. def using[U](p: RowParser[U]): SimpleSql[U]

    Prepares query with given row parser.

    Prepares query with given row parser.

    import anorm.{ SQL, SqlParser }
    
    val res: Int = SQL("SELECT 1").using(SqlParser.scalar[Int]).single
    // Equivalent to: SQL("SELECT 1").as(SqlParser.scalar[Int].single)
  34. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  35. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  36. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  37. def withIterator[T](op: (Iterator[Row]) ⇒ T)(implicit connection: Connection): Either[List[Throwable], T]

    Processes all or some rows through iterator for current results.

    Processes all or some rows through iterator for current results.

    op

    Operation applied with row iterator

    val l: Either[List[Throwable], List[Row]] = SQL"SELECT * FROM Test".
    withIterator(_.toList)
    Definition Classes
    Sql
  38. def withQueryTimeout(seconds: Option[Int]): SimpleSql[T]

Deprecated Value Members

  1. def apply()(implicit connection: Connection): Stream[Row]

    Executes this SQL statement as query, returns result as Row stream.

    Executes this SQL statement as query, returns result as Row stream.

    Definition Classes
    Sql
    Annotations
    @deprecated
    Deprecated

    (Since version 2.4) Use fold, foldWhile or withIterator instead, which manages resources and memory

  2. def execute1(getGeneratedKeys: Boolean = false)(implicit connection: Connection): (PreparedStatement, Int)

    Definition Classes
    Sql
    Annotations
    @deprecated
    Deprecated

    (Since version 2.3.2) Will be made private, use executeUpdate or executeInsert

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from Sql

Inherited from AnyRef

Inherited from Any

Ungrouped