case class SimpleSql[T](sql: SqlQuery, params: Map[String, ParameterValue], defaultParser: RowParser[T], resultSetOnFirstRow: Boolean = false) extends Sql with Product with Serializable
- Alphabetic
- By Inheritance
- SimpleSql
- Serializable
- Serializable
- Product
- Equals
- Sql
- WithResult
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new SimpleSql(sql: SqlQuery, params: Map[String, ParameterValue], defaultParser: RowParser[T], resultSetOnFirstRow: Boolean = false)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
as[T](parser: ResultSetParser[T])(implicit connection: Connection): T
Converts this query result as
T
, using parser.Converts this query result as
T
, using parser.- parser
the result parser
- Definition Classes
- WithResult
- See also
#asTry
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
asTry[T](parser: ResultSetParser[T], aliaser: ColumnAliaser = ColumnAliaser.empty)(implicit connection: Connection): Try[T]
Converts this query result as
T
, using parser.Converts this query result as
T
, using parser.- parser
the result parser
- aliaser
the column aliaser
- Definition Classes
- WithResult
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
- val defaultParser: RowParser[T]
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
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
-
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
-
def
executeInsert1[A](generatedColumn: String, otherColumns: String*)(generatedKeysParser: ResultSetParser[A] = SqlParser.scalar[Long].singleOpt)(implicit connection: Connection): Try[A]
Executes this SQL as an insert statement.
Executes this SQL as an insert statement.
- generatedColumn
the first (mandatory) column name to consider from the generated keys
- otherColumns
the other (possibly none) column name(s) from the generated keys
- generatedKeysParser
the 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").executeInsert1("generatedCol", "colB")() val keys2 = SQL("INSERT INTO Test(x) VALUES ({x})"). on("x" -> "y").executeInsert1("generatedCol")(scalar[String].singleOpt) // ... generated string key
- Definition Classes
- Sql
-
def
executeInsert2[A](generatedColumn: String, otherColumns: String*)(generatedKeysParser: ResultSetParser[A] = SqlParser.scalar[Long].singleOpt, aliaser: ColumnAliaser)(implicit connection: Connection): Try[A]
Executes this SQL as an insert statement.
Executes this SQL as an insert statement.
- generatedColumn
the first (mandatory) column name to consider from the generated keys
- otherColumns
the other (possibly none) column name(s) from the generated keys
- generatedKeysParser
the parser for generated key (default: scalar long)
- aliaser
the column aliaser
- returns
Parsed generated keys
import anorm.SqlParser.scalar val keys1 = SQL("INSERT INTO Test(x) VALUES ({x})"). on("x" -> "y").executeInsert1("generatedCol", "colB")() val keys2 = SQL("INSERT INTO Test(x) VALUES ({x})"). on("x" -> "y").executeInsert1("generatedCol")(scalar[String].singleOpt) // ... generated string key
- Definition Classes
- Sql
-
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
-
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" )
-
def
fetchSize: Option[Int]
Fetch size
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
fold[T](z: ⇒ T, aliaser: ColumnAliaser)(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
- aliaser
the column aliaser
- op
Aggregate operator
- returns
Either list of failures at left, or aggregated value
- Definition Classes
- WithResult
- See also
#withResult
#foldWhile
-
def
foldWhile[T](z: ⇒ T, aliaser: ColumnAliaser)(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
- aliaser
the column aliaser
- 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
- WithResult
- See also
#withResult
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def map[A](f: (T) ⇒ A): SimpleSql[A]
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
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")
-
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
- val params: Map[String, ParameterValue]
-
final
def
preparedStatement(connection: Connection, generatedColumn: String, generatedColumns: Seq[String]): ManagedResource[PreparedStatement]
- Definition Classes
- Sql
-
def
resultSet(connection: Connection): ManagedResource[ResultSet]
Executes this statement as query (see executeQuery) and returns result.
Executes this statement as query (see executeQuery) and returns result.
- Attributes
- protected
- Definition Classes
- Sql → WithResult
-
val
resultSetOnFirstRow: Boolean
- Definition Classes
- SimpleSql → WithResult
- val sql: SqlQuery
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
unsafeStatement(connection: Connection, generatedColumn: String, generatedColumns: Seq[String]): PreparedStatement
- Definition Classes
- SimpleSql → Sql
-
def
unsafeStatement(connection: Connection, getGeneratedKeys: Boolean = false): PreparedStatement
- Definition Classes
- SimpleSql → Sql
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
withFetchSize(count: Option[Int]): SimpleSql[T]
Returns this query with the fetch suze updated to the row
count
.Returns this query with the fetch suze updated to the row
count
.- See also
-
def
withQueryTimeout(seconds: Option[Int]): SimpleSql[T]
Returns a copy with updated timeout.
-
def
withResult[T](op: (Option[Cursor]) ⇒ T, aliaser: ColumnAliaser)(implicit connection: Connection): Either[List[Throwable], T]
Processes all or some rows from current result.
Processes all or some rows from current result.
- op
Operation applied with row cursor
@annotation.tailrec def go(c: Option[Cursor], l: List[Row]): List[Row] = c match { case Some(cursor) => go(cursor.next, l :+ cursor.row) case _ => l } val l: Either[List[Throwable], List[Row]] = SQL"SELECT * FROM Test".withResult(go)
- Definition Classes
- WithResult
-
def
withResult[T](op: (Option[Cursor]) ⇒ T)(implicit connection: Connection): Either[List[Throwable], T]
Processes all or some rows from current result.
Processes all or some rows from current result.
- op
Operation applied with row cursor
- Definition Classes
- WithResult
-
def
withResultSetOnFirstRow(onFirst: Boolean): SimpleSql[T]
Returns a copy with updated flag.
Deprecated Value Members
-
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
- WithResult
- Annotations
- @deprecated
- Deprecated
(Since version 2.5.1) Use
fold
with empty ColumnAliaser- See also
#withResult
#foldWhile
-
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
- WithResult
- Annotations
- @deprecated
- Deprecated
(Since version 2.5.1) Use
foldWhile
with empty ColumnAliaser- See also
#withResult
-
def
preparedStatement(connection: Connection, getGeneratedKeys: Boolean = false): ManagedResource[PreparedStatement]
- Definition Classes
- Sql
- Annotations
- @deprecated
- Deprecated
(Since version 2.5.2) Do not override. Will be made final
-
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)
- Annotations
- @deprecated
- Deprecated
(Since version 2.5.1) Use as