Object/Trait

anorm

ToStatement

Related Docs: trait ToStatement | package anorm

Permalink

object ToStatement extends ToStatementPriority1 with JodaToStatement with JavaTimeToStatement

Provided conversions to set statement parameter.

Source
ToStatement.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. ToStatement
  2. JavaTimeToStatement
  3. JodaToStatement
  4. ToStatementPriority1
  5. ToStatementPriority0
  6. AnyRef
  7. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. implicit def arrayToParameter[A <: AnyRef](implicit m: ParameterMetaData[A]): ToStatement[Array[A]] with NotNullGuard

    Permalink

    Sets an array parameter on statement.

    Sets an array parameter on statement.

    Definition Classes
    ToStatementPriority0
    See also

    java.sql.Array

    SQL("INSERT INTO Table(arr) VALUES {a}").on("a" -> Array("A", "2", "C"))
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. implicit def binaryStreamToStatement[S <: InputStream]: ToStatement[S]

    Permalink

    Sets a binary stream as parameter on statement.

    Sets a binary stream as parameter on statement. For null value, setNull with LONGVARBINARY is called on statement.

    SQL("INSERT INTO Table(bin) VALUES {b}").on("b" -> inputStream)
    Definition Classes
    ToStatementPriority0
  7. implicit def blobToStatement[B <: Blob]: ToStatement[B]

    Permalink

    Sets a blob as parameter on statement.

    Sets a blob as parameter on statement. For null value, setNull with BLOB is called on statement.

    val blob = con.createBlob()
    blob.setBytes(1, byteArray)
    SQL("INSERT INTO Table(bin) VALUES {b}").on("b" -> blob)
    Definition Classes
    ToStatementPriority0
  8. implicit object booleanToStatement extends ToStatement[Boolean]

    Permalink

    Sets boolean value on statement.

    Sets boolean value on statement.

    SQL("SELECT * FROM Test WHERE enabled = {b}").on('b -> true)
    Definition Classes
    ToStatementPriority0
  9. implicit object byteArrayToStatement extends ToStatement[Array[Byte]]

    Permalink

    Sets an array of byte as parameter on statement.

    Sets an array of byte as parameter on statement. For null value, setNull with LONGVARBINARY is called on statement.

    SQL("INSERT INTO Table(bin) VALUES {b}").on("b" -> arrayOfBytes)
    Definition Classes
    ToStatementPriority1
  10. implicit object byteToStatement extends ToStatement[Byte]

    Permalink

    Sets byte value on statement.

    Sets byte value on statement.

    SQL("SELECT * FROM Test WHERE flag = {b}").on('b -> 1.toByte)
    Definition Classes
    ToStatementPriority0
  11. implicit object charToStatement extends ToStatement[Char]

    Permalink

    Sets character as parameter value.

    Sets character as parameter value.

    SQL("SELECT * FROM tbl WHERE flag = {c}").on("c" -> 'f')
    Definition Classes
    ToStatementPriority0
  12. implicit def characterStreamToStatement[R <: Reader]: ToStatement[R]

    Permalink

    Sets a character stream as parameter on statement.

    Sets a character stream as parameter on statement. For null value, setNull with VARCHAR is called on statement.

    SQL("INSERT INTO Table(chars) VALUES {c}").on("c" -> reader)
    Definition Classes
    ToStatementPriority0
  13. implicit object characterToStatement extends ToStatement[Character]

    Permalink

    Sets Java Character as parameter value.

    Sets Java Character as parameter value. For null character, setNull with VARCHAR is called on statement.

    SQL("SELECT * FROM tbl WHERE flag = {c}").
      on("c" -> new java.lang.Character('f'))
    Definition Classes
    ToStatementPriority0
  14. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  15. implicit object dateToStatement extends ToStatement[Date]

    Permalink

    Sets date as statement parameter.

    Sets date as statement parameter. For null value, setNull with TIMESTAMP is called on statement.

    SQL("UPDATE tbl SET modified = {d}").on('d -> new Date())
    Definition Classes
    ToStatementPriority0
  16. implicit object doubleToStatement extends ToStatement[Double]

    Permalink

    Sets double value on statement.

    Sets double value on statement.

    SQL("SELECT * FROM Test WHERE flag = {b}").on('b -> 1d)
    Definition Classes
    ToStatementPriority0
  17. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  18. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  19. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  20. implicit object floatToStatement extends ToStatement[Float]

    Permalink

    Sets float value on statement.

    Sets float value on statement.

    SQL("SELECT * FROM Test WHERE flag = {b}").on('b -> 1f)
    Definition Classes
    ToStatementPriority0
  21. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  22. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  23. implicit def instantToStatement(implicit meta: ParameterMetaData[Instant]): ToStatement[Instant]

    Permalink

    Sets a temporal instant on statement.

    Sets a temporal instant on statement.

    import java.time.Instant
    import anorm.Java8._
    
    SQL("SELECT * FROM Test WHERE time < {b}").on('b -> Instant.now)
    Definition Classes
    JavaTimeToStatement
  24. implicit object intToStatement extends ToStatement[Int]

    Permalink

    Sets integer value on statement.

    Sets integer value on statement.

    SQL("SELECT * FROM Test WHERE flag = {b}").on('b -> 1)
    Definition Classes
    ToStatementPriority0
  25. implicit object integerToStatement extends ToStatement[Integer]

    Permalink

    Sets Java Integer object on statement.

    Sets Java Integer object on statement. For null value, setNull with INTEGER is called on statement.

    SQL("SELECT * FROM Test WHERE flag = {b}").
      on('b -> new java.lang.Integer(1))
    Definition Classes
    ToStatementPriority0
  26. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  27. implicit object javaBigDecimalToStatement extends ToStatement[BigDecimal]

    Permalink

    Sets Java big decimal on statement.

    Sets Java big decimal on statement. Value null is accepted.

    SQL("UPDATE tbl SET max = {m}").on('m -> new java.math.BigDecimal(10.02f))
    Definition Classes
    ToStatementPriority0
  28. implicit object javaBigIntegerToStatement extends ToStatement[BigInteger]

    Permalink

    Sets Java big integer on statement.

    Sets Java big integer on statement. For null value, setNull with NUMERIC is called on statement.

    SQL("UPDATE tbl SET max = {m}").on('m -> new BigInteger(15))
    Definition Classes
    ToStatementPriority0
  29. implicit object javaBooleanToStatement extends ToStatement[Boolean]

    Permalink

    Sets Java Boolean object on statement.

    Sets Java Boolean object on statement. For null value, setNull with BOOLEAN is called on statement.

    SQL("SELECT * FROM Test WHERE enabled = {b}").
      on('b -> java.lang.Boolean.TRUE)
    Definition Classes
    ToStatementPriority0
  30. implicit object javaByteToStatement extends ToStatement[Byte]

    Permalink

    Sets Java Byte object on statement.

    Sets Java Byte object on statement. For null value, setNull with TINYINT is called on statement.

    SQL("SELECT * FROM Test WHERE flag = {b}").on('b -> new java.lang.Byte(1))
    Definition Classes
    ToStatementPriority0
  31. implicit object javaDoubleToStatement extends ToStatement[Double]

    Permalink

    Sets Java Double object on statement.

    Sets Java Double object on statement. For null value, setNull with DOUBLE is called on statement.

    SQL("SELECT * FROM Test WHERE flag = {b}").
      on('b -> new java.lang.Double(1d))
    Definition Classes
    ToStatementPriority0
  32. implicit object javaFloatToStatement extends ToStatement[Float]

    Permalink

    Sets Java Float object on statement.

    Sets Java Float object on statement. For null value, setNull with FLOAT is called on statement.

    SQL("SELECT * FROM Test WHERE flag = {b}").
      on('b -> new java.lang.Float(1f))
    Definition Classes
    ToStatementPriority0
  33. implicit object javaLongToStatement extends ToStatement[Long]

    Permalink

    Sets Java Long object on statement.

    Sets Java Long object on statement. For null value, setNull with BIGINT is called on statement.

    SQL("SELECT * FROM Test WHERE flag = {b}").
      on('b -> new java.lang.Long(1l))
    Definition Classes
    ToStatementPriority0
  34. implicit object javaShortToStatement extends ToStatement[Short]

    Permalink

    Sets Java Short object on statement.

    Sets Java Short object on statement. For null value, setNull with SMALLINT is called on statement.

    SQL("SELECT * FROM Test WHERE flag = {b}").
      on('b -> new java.lang.Short(1.toShort))
    Definition Classes
    ToStatementPriority0
  35. implicit def jodaDateTimeToStatement(implicit meta: ParameterMetaData[DateTime]): ToStatement[DateTime]

    Permalink

    Sets joda-time DateTime as statement parameter.

    Sets joda-time DateTime as statement parameter. For null value, setNull with TIMESTAMP is called on statement.

    import org.joda.time.DateTime
    
    SQL("UPDATE tbl SET modified = {d}").on('d -> new DateTime())
    Definition Classes
    JodaToStatement
  36. implicit def jodaInstantToStatement(implicit meta: ParameterMetaData[Instant]): ToStatement[Instant]

    Permalink

    Sets joda-time Instant as statement parameter.

    Sets joda-time Instant as statement parameter. For null value, setNull with TIMESTAMP is called on statement.

    import org.joda.time.Instant
    
    SQL("UPDATE tbl SET modified = {d}").on('d -> new Instant())
    Definition Classes
    JodaToStatement
  37. implicit def jodaLocalDateTimeToStatement(implicit meta: ParameterMetaData[LocalDateTime]): ToStatement[LocalDateTime]

    Permalink

    Sets a local date/time on statement.

    Sets a local date/time on statement.

    import org.joda.time.LocalDateTime
    
    SQL("SELECT * FROM Test WHERE time < {b}").on('b -> LocalDateTime.now)
    Definition Classes
    JodaToStatement
  38. implicit def jodaLocalDateToStatement(implicit meta: ParameterMetaData[LocalDate]): ToStatement[LocalDate]

    Permalink

    Sets a local date on statement.

    Sets a local date on statement.

    import org.joda.time.LocalDate
    
    SQL("SELECT * FROM Test WHERE time < {b}").on('b -> LocalDate.now)
    Definition Classes
    JodaToStatement
  39. implicit def listToStatement[A](implicit c: ToStatement[A]): ToStatement[List[A]]

    Permalink

    Sets multi-value parameter from list on statement.

    Sets multi-value parameter from list on statement.

    SQL("SELECT * FROM Test WHERE cat IN ({categories})").
      on('categories -> List(1, 3, 4)
    Definition Classes
    ToStatementPriority0
  40. implicit def localDateTimeToStatement(implicit meta: ParameterMetaData[LocalDateTime]): ToStatement[LocalDateTime]

    Permalink

    Sets a local date/time on statement.

    Sets a local date/time on statement.

    import java.time.LocalDateTime
    import anorm.Java8._
    
    SQL("SELECT * FROM Test WHERE time < {b}").on('b -> LocalDateTime.now)
    Definition Classes
    JavaTimeToStatement
  41. implicit object longToStatement extends ToStatement[Long]

    Permalink

    Sets long value on statement.

    Sets long value on statement.

    SQL("SELECT * FROM Test WHERE flag = {b}").on('b -> 1l)
    Definition Classes
    ToStatementPriority0
  42. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  43. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  44. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  45. implicit object objectToStatement extends ToStatement[Object]

    Permalink

    Sets opaque value as statement parameter.

    Sets opaque value as statement parameter. UNSAFE: It's set using java.sql.PreparedStatement.setObject.

    SQL("EXEC indexed_at {d}").on('d -> anorm.Object(new java.util.Date()))
    Definition Classes
    ToStatementPriority0
  46. implicit def optionToStatement[A](implicit c: ToStatement[A], meta: ParameterMetaData[A]): ToStatement[Option[A]] with NotNullGuard

    Permalink

    Sets optional A inferred as Option[A].

    Sets optional A inferred as Option[A].

    SQL("SELECT * FROM Test WHERE category = {c}").on('c -> Option("cat"))
    SQL"SELECT * FROM Test WHERE nullable_int = \${Option.empty[Int]}"
    Definition Classes
    ToStatementPriority0
  47. implicit object scalaBigDecimalToStatement extends ToStatement[BigDecimal]

    Permalink

    Sets big decimal on statement.

    Sets big decimal on statement. For null value, setNull with DECIMAL is called on statement.

    SQL("UPDATE tbl SET max = {m}").on('m -> BigDecimal(10.02f))
    Definition Classes
    ToStatementPriority0
  48. implicit object scalaBigIntegerToStatement extends ToStatement[BigInt]

    Permalink

    Sets big integer on statement.

    Sets big integer on statement. For null value, setNull with NUMERIC is called on statement.

    SQL("UPDATE tbl SET max = {m}").on('m -> BigInt(15))
    Definition Classes
    ToStatementPriority0
  49. implicit def seqParamToStatement[A](implicit c: ToStatement[Seq[A]]): ToStatement[SeqParameter[A]] with NotNullGuard

    Permalink

    Sets multi-value parameter on statement, with custom formatting (using anorm.SeqParameter).

    Sets multi-value parameter on statement, with custom formatting (using anorm.SeqParameter).

    import anorm.SeqParameter
    SQL("SELECT * FROM Test t WHERE {categories}").
      on('categories -> SeqParameter(
        values = Seq("a", "b", "c"), separator = " OR ",
        pre = "EXISTS (SELECT NULL FROM j WHERE t.id=j.id AND name=",
        post = ")"))
    Definition Classes
    ToStatementPriority0
  50. implicit def seqToStatement[A](implicit c: ToStatement[A]): ToStatement[Seq[A]]

    Permalink

    Sets multi-value parameter from sequence on statement.

    Sets multi-value parameter from sequence on statement.

    SQL("SELECT * FROM Test WHERE cat IN ({categories})").
      on('categories -> Seq("a", "b", "c")
    Definition Classes
    ToStatementPriority0
  51. implicit def setToStatement[A](implicit c: ToStatement[A]): ToStatement[Set[A]]

    Permalink

    Sets multi-value parameter from set on statement.

    Sets multi-value parameter from set on statement.

    SQL("SELECT * FROM Test WHERE cat IN ({categories})").
      on('categories -> Set(1, 3, 4)
    Definition Classes
    ToStatementPriority0
  52. implicit object shortToStatement extends ToStatement[Short]

    Permalink

    Sets short value on statement.

    Sets short value on statement.

    SQL("SELECT * FROM Test WHERE flag = {b}").on('b -> 1.toShort)
    Definition Classes
    ToStatementPriority0
  53. implicit def someToStatement[A](implicit c: ToStatement[A]): ToStatement[Some[A]] with NotNullGuard

    Permalink

    Sets not empty optional A inferred as Some[A].

    Sets not empty optional A inferred as Some[A].

    SQL("SELECT * FROM Test WHERE category = {c}").on('c -> Some("cat"))
    Definition Classes
    ToStatementPriority0
  54. implicit def sortedSetToStatement[A](implicit c: ToStatement[A]): ToStatement[SortedSet[A]]

    Permalink

    Sets multi-value parameter from sorted set on statement.

    Sets multi-value parameter from sorted set on statement.

    SQL("SELECT * FROM Test WHERE cat IN ({categories})").
      on('categories -> SortedSet("a", "b", "c")
    Definition Classes
    ToStatementPriority0
  55. implicit def streamToStatement[A](implicit c: ToStatement[A]): ToStatement[Stream[A]]

    Permalink

    Sets multi-value parameter from stream on statement.

    Sets multi-value parameter from stream on statement.

    SQL("SELECT * FROM Test WHERE cat IN ({categories})").
      on('categories -> Stream(1, 3, 4)
    Definition Classes
    ToStatementPriority0
  56. implicit object stringToStatement extends ToStatement[String]

    Permalink

    Sets string as parameter value.

    Sets string as parameter value. Value null is accepted.

    SQL("SELECT * FROM tbl WHERE name = {n}").on("n" -> "str")
    Definition Classes
    ToStatementPriority0
  57. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  58. implicit object timestampToStatement extends ToStatement[Timestamp]

    Permalink

    Sets timestamp as statement parameter.

    Sets timestamp as statement parameter. Value null is accepted.

    SQL("UPDATE tbl SET modified = {ts}").
      on('ts -> new Timestamp(date.getTime))
    Definition Classes
    ToStatementPriority0
  59. implicit def timestampWrapper1ToStatement[T <: TimestampWrapper1]: ToStatement[T]

    Permalink

    Sets a wrapped timestamp as statement parameter.

    Sets a wrapped timestamp as statement parameter. For null value, setNull with TIMESTAMP is called on statement.

    val wrapper = new {
      // Any value with a `.getTimestamp`
      val getTimestamp = new java.sql.Timestamp(123L)
    }
    
    SQL("UPDATE tbl SET modified = {ts}").on('ts -> wrapper)
    Definition Classes
    ToStatementPriority0
  60. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  61. implicit object uuidToStatement extends ToStatement[UUID]

    Permalink

    Sets UUID as statement parameter.

    Sets UUID as statement parameter. For null value, setNull with VARCHAR is called on statement.

    SQL("INSERT INTO lang_tbl(id, name) VALUE ({i}, {n})").
      on("i" -> JUUID.randomUUID(), "n" -> "lang")
    Definition Classes
    ToStatementPriority0
  62. implicit def vectorToStatement[A](implicit c: ToStatement[A]): ToStatement[Vector[A]]

    Permalink

    Sets multi-value parameter from vector on statement.

    Sets multi-value parameter from vector on statement.

    SQL("SELECT * FROM Test WHERE cat IN ({categories})").
      on('categories -> Vector("a", "b", "c")
    Definition Classes
    ToStatementPriority0
  63. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  66. implicit def zonedDateTimeToStatement(implicit meta: ParameterMetaData[ZonedDateTime]): ToStatement[ZonedDateTime]

    Permalink

    Sets a zoned date/time on statement.

    Sets a zoned date/time on statement.

    import java.time.ZonedDateTime
    import anorm.Java8._
    
    SQL("SELECT * FROM Test WHERE time < {b}").on('b -> ZonedDateTime.now)
    Definition Classes
    JavaTimeToStatement

Deprecated Value Members

  1. implicit object noneToStatement extends ToStatement[None.type]

    Permalink

    Sets null for None value.

    Sets null for None value.

    SQL("SELECT * FROM Test WHERE category = {c}")
      .on('c -> None)
    Definition Classes
    ToStatementPriority0
    Annotations
    @deprecated
    Deprecated

    (Since version 2.3.7) Parameter value should be passed using Option.empty[T]

Inherited from JavaTimeToStatement

Inherited from JodaToStatement

Inherited from ToStatementPriority1

Inherited from ToStatementPriority0

Inherited from AnyRef

Inherited from Any

Ungrouped