scalikejdbc

package scalikejdbc

ScalikeJDBC - SQL-Based DB Access Library for Scala

Just write SQL:

ScalikeJDBC is a SQL-based DB access library for Scala developers. This library naturally wraps JDBC APIs and provides you easy-to-use APIs. Users do nothing other than writing SQL and mapping from java.sql.ResultSet objects to Scala values.

Basic Usage:

Using DBSession:

import scalikejdbc._
import org.joda.time.DateTime
case class User(id: Long, name: String, birthday: Option[DateTime])

val activeUsers: List[User] = DB readOnly { session =>
  session.list("select * from users where active = ?", true) { rs =>
    User(id = rs.long("id"), name = rs.string("name"), birthday = Option(rs.date("birthday")).map(_.toDateTime))
  }
}

Using SQL:

import scalikejdbc._
import org.joda.time.DateTime
case class User(id: Long, name: String, birthday: Option[DateTime])

val activeUsers: List[User] = DB readOnly { implicit session =>
  SQL("select * from users where active = ?")
    .bind(true)
    .map { rs => User(id = rs.long("id"), name = rs.string("name"), birthday = Option(rs.date("birthday")).map(_.toDateTime)) }.list.apply()
}

or

val activeUsers: List[User] = DB readOnly { implicit session =>
  SQL("select * from users where active = /*'active*/rue")
    .bindByName('active -> true)
    .map { rs => User(id = rs.long("id"), name = rs.string("name"), birthday = Option(rs.date("birthday")).map(_.toDateTime)) }.list.apply()
}
Visibility
  1. Public
  2. All

Type Members

  1. case class ActiveSession (conn: Connection, tx: Option[Tx], isReadOnly: Boolean) extends DBSession with Product with Serializable

    Active session implementation of DBSession.

  2. trait AllOutputDecisionsUnsupported [Z, E <: WithExtractor] extends SQL[Z, E]

    All output decisions are unsupported by default.

  3. class AuthenticatedDataSourceConnectionPool extends ConnectionPool

    Connection Pool using external DataSource

  4. type Closable = AnyRef { def close(): Unit }

    Definition Classes
    package
  5. class CommonsConnectionPool extends ConnectionPool

    Commons DBCP Connection Pool

  6. class ConnectionPool extends AnyRef

    Connection Pool

  7. trait ConnectionPoolContext extends AnyRef

    Connection pool context

  8. trait ConnectionPoolFactory extends AnyRef

    Connection Pool Factory

  9. case class ConnectionPoolSettings (initialSize: Int, maxSize: Int, connectionTimeoutMillis: Long, validationQuery: String) extends Product with Serializable

    Settings for ConnectionPool

  10. case class DB (conn: Connection) extends DBConnection with Product with Serializable

    Basic Database Accessor

  11. trait DBConnection extends LogSupport

    Basic Database Accessor

  12. trait DBSession extends LogSupport

    DB Session

  13. class DataSourceConnectionPool extends ConnectionPool

    Connection Pool using external DataSource

  14. trait EntityEquality extends AnyRef

    Entity identifier provider for equality (especially for scalikejdbc.

  15. trait HasExtractor extends WithExtractor

    Represents that this SQL already has an extractor

  16. case class IllegalRelationshipException (message: String) extends IllegalStateException with Product with Serializable

    Exception which represents that an illegal relationship is found.

  17. case class InvalidColumnNameException (name: String) extends Exception with Product with Serializable

    Exception which represents invalid key is specified.

  18. case class JDBCSettings (url: String, user: String, password: String, driverName: String) extends Product with Serializable

    JDBC Settings

  19. case class JDBCUrl (host: String, port: Int, database: String) extends Product with Serializable

    JDBC URL which contains host, port and database name

  20. class LocalTimeConverter extends AnyRef

    org.

  21. case class LoggingSQLAndTimeSettings (enabled: Boolean, singleLineMode: Boolean, printUnprocessedStackTrace: Boolean, stackTraceDepth: Int, logLevel: Symbol, warningEnabled: Boolean, warningThresholdMillis: Long, warningLogLevel: Symbol) extends Product with Serializable

    Settings for logging SQL and timing

  22. trait LowPriorityTypeBinderImplicits extends AnyRef

  23. case class MultipleConnectionPoolContext (contexts: (Any, ConnectionPool)*) extends ConnectionPoolContext with Product with Serializable

    Multiple connection pool context

  24. case class NameBindingSQLValidatorSettings (ignoredParams: IgnoredParamsValidation) extends Product with Serializable

    Settings for Name binding SQL validator

  25. case class NamedAutoSession (name: Any) extends DBSession with Product with Serializable

    Represents that already existing session will be used or a new session which is retrieved from named connection pool will be started.

  26. case class NamedDB (name: Any, context: ConnectionPoolContext) extends DBConnection with Product with Serializable

    Named Basic DB Accessor

  27. trait NoExtractor extends WithExtractor

    Represents that this SQL doesn't have an extractor yet

  28. class OneToManies2SQL [A, B1, B2, E <: WithExtractor, Z] extends SQL[Z, E] with AllOutputDecisionsUnsupported[Z, E]

  29. class OneToManies2SQLToList [A, B1, B2, E <: WithExtractor, Z] extends SQL[Z, E] with SQLToList[Z, E] with OutputDecisions[Z, E] with OneToManies2Extractor[A, B1, B2, E, Z]

  30. class OneToManies2SQLToOption [A, B1, B2, E <: WithExtractor, Z] extends SQL[Z, E] with SQLToOption[Z, E] with AllOutputDecisionsUnsupported[Z, E] with OneToManies2Extractor[A, B1, B2, E, Z]

  31. class OneToManies2SQLToTraversable [A, B1, B2, E <: WithExtractor, Z] extends SQL[Z, E] with SQLToTraversable[Z, E] with AllOutputDecisionsUnsupported[Z, E] with OneToManies2Extractor[A, B1, B2, E, Z]

  32. class OneToManies3SQL [A, B1, B2, B3, E <: WithExtractor, Z] extends SQL[Z, E] with AllOutputDecisionsUnsupported[Z, E]

  33. class OneToManies3SQLToList [A, B1, B2, B3, E <: WithExtractor, Z] extends SQL[Z, E] with SQLToList[Z, E] with AllOutputDecisionsUnsupported[Z, E] with OneToManies3Extractor[A, B1, B2, B3, E, Z]

  34. class OneToManies3SQLToOption [A, B1, B2, B3, E <: WithExtractor, Z] extends SQL[Z, E] with SQLToOption[Z, E] with AllOutputDecisionsUnsupported[Z, E] with OneToManies3Extractor[A, B1, B2, B3, E, Z]

  35. class OneToManies3SQLToTraversable [A, B1, B2, B3, E <: WithExtractor, Z] extends SQL[Z, E] with SQLToTraversable[Z, E] with AllOutputDecisionsUnsupported[Z, E] with OneToManies3Extractor[A, B1, B2, B3, E, Z]

  36. class OneToManies4SQL [A, B1, B2, B3, B4, E <: WithExtractor, Z] extends SQL[Z, E] with AllOutputDecisionsUnsupported[Z, E]

  37. class OneToManies4SQLToList [A, B1, B2, B3, B4, E <: WithExtractor, Z] extends SQL[Z, E] with SQLToList[Z, E] with AllOutputDecisionsUnsupported[Z, E] with OneToManies4Extractor[A, B1, B2, B3, B4, E, Z]

  38. class OneToManies4SQLToOption [A, B1, B2, B3, B4, E <: WithExtractor, Z] extends SQL[Z, E] with SQLToOption[Z, E] with AllOutputDecisionsUnsupported[Z, E] with OneToManies4Extractor[A, B1, B2, B3, B4, E, Z]

  39. class OneToManies4SQLToTraversable [A, B1, B2, B3, B4, E <: WithExtractor, Z] extends SQL[Z, E] with SQLToTraversable[Z, E] with AllOutputDecisionsUnsupported[Z, E] with OneToManies4Extractor[A, B1, B2, B3, B4, E, Z]

  40. class OneToManies5SQL [A, B1, B2, B3, B4, B5, E <: WithExtractor, Z] extends SQL[Z, E] with AllOutputDecisionsUnsupported[Z, E]

  41. class OneToManies5SQLToList [A, B1, B2, B3, B4, B5, E <: WithExtractor, Z] extends SQL[Z, E] with SQLToList[Z, E] with AllOutputDecisionsUnsupported[Z, E] with OneToManies5Extractor[A, B1, B2, B3, B4, B5, E, Z]

  42. class OneToManies5SQLToOption [A, B1, B2, B3, B4, B5, E <: WithExtractor, Z] extends SQL[Z, E] with SQLToOption[Z, E] with AllOutputDecisionsUnsupported[Z, E] with OneToManies5Extractor[A, B1, B2, B3, B4, B5, E, Z]

  43. class OneToManies5SQLToTraversable [A, B1, B2, B3, B4, B5, E <: WithExtractor, Z] extends SQL[Z, E] with SQLToTraversable[Z, E] with AllOutputDecisionsUnsupported[Z, E] with OneToManies5Extractor[A, B1, B2, B3, B4, B5, E, Z]

  44. class OneToManySQL [A, B, E <: WithExtractor, Z] extends SQL[Z, E] with AllOutputDecisionsUnsupported[Z, E]

  45. class OneToManySQLToList [A, B, E <: WithExtractor, Z] extends SQL[Z, E] with SQLToList[Z, E] with AllOutputDecisionsUnsupported[Z, E] with OneToManyExtractor[A, B, E, Z]

  46. class OneToManySQLToOption [A, B, E <: WithExtractor, Z] extends SQL[Z, E] with SQLToOption[Z, E] with AllOutputDecisionsUnsupported[Z, E] with OneToManyExtractor[A, B, E, Z]

  47. class OneToManySQLToTraversable [A, B, E <: WithExtractor, Z] extends SQL[Z, E] with SQLToTraversable[Z, E] with AllOutputDecisionsUnsupported[Z, E] with OneToManyExtractor[A, B, E, Z]

  48. class OneToOneSQL [A, B, E <: WithExtractor, Z] extends SQL[Z, E] with AllOutputDecisionsUnsupported[Z, E]

  49. class OneToOneSQLToList [A, B, E <: WithExtractor, Z] extends SQL[Z, E] with SQLToList[Z, E] with AllOutputDecisionsUnsupported[Z, E] with OneToOneExtractor[A, B, E, Z]

  50. class OneToOneSQLToOption [A, B, E <: WithExtractor, Z] extends SQL[Z, E] with SQLToOption[Z, E] with AllOutputDecisionsUnsupported[Z, E] with OneToOneExtractor[A, B, E, Z]

  51. class OneToOneSQLToTraversable [A, B, E <: WithExtractor, Z] extends SQL[Z, E] with SQLToTraversable[Z, E] with AllOutputDecisionsUnsupported[Z, E] with OneToOneExtractor[A, B, E, Z]

  52. class OneToXSQL [A, E <: WithExtractor, Z] extends SQL[Z, E] with AllOutputDecisionsUnsupported[Z, E]

    Endpoint of one-to-x APIs

  53. case class ReadOnlyNamedAutoSession (name: Any) extends DBSession with Product with Serializable

    Represents that already existing session will be used or a new read-only session which is retrieved from named connnection pool will be started.

  54. class ResultSetCursor extends AnyRef

    java.

  55. case class ResultSetExtractorException (message: String, e: Option[Exception]) extends IllegalArgumentException with Product with Serializable

    Exception which represents failure on ResultSet extraction.

  56. class ResultSetTraversable extends Traversable[WrappedResultSet]

    scala.

  57. class SQL [A, E <: WithExtractor] extends Extractor[A]

    SQL abstraction.

  58. class SQLBatch extends AnyRef

    SQL which execute java.

  59. class SQLExecution extends AnyRef

    SQL which execute java.

  60. trait SQLFormatter extends AnyRef

    SQL formatter

  61. case class SQLFormatterSettings (formatterClassName: Option[String]) extends LogSupport with Product with Serializable

    Settings for SQL formatter

  62. trait SQLToList [A, E <: WithExtractor] extends SQL[A, E] with Extractor[A]

    SQL to List

  63. class SQLToListImpl [A, E <: WithExtractor] extends SQL[A, E] with OutputDecisions[A, E] with SQLToList[A, E]

    SQL which execute java.

  64. trait SQLToOption [A, E <: WithExtractor] extends SQL[A, E] with Extractor[A]

    SQL to Option

  65. class SQLToOptionImpl [A, E <: WithExtractor] extends SQL[A, E] with OutputDecisions[A, E] with SQLToOption[A, E]

    SQL which execute java.

  66. trait SQLToTraversable [A, E <: WithExtractor] extends SQL[A, E] with Extractor[A]

    SQL to Traversable

  67. class SQLToTraversableImpl [A, E <: WithExtractor] extends SQL[A, E] with OutputDecisions[A, E] with SQLToTraversable[A, E]

    SQL which execute java.

  68. class SQLUpdate extends AnyRef

    SQL which execute java.

  69. class SQLUpdateWithGeneratedKey extends AnyRef

    SQL which execute java.

  70. class ScalaBigDecimalConverter extends AnyRef

    BigDecimal converter.

  71. case class StatementExecutor (underlying: PreparedStatement, template: String, singleParams: Seq[Any], isBatch: Boolean) extends LogSupport with Product with Serializable

    java.

  72. case class StringSQLRunner (sql: String) extends LogSupport with Product with Serializable

    String SQL Runner

  73. case class TooManyRowsException (expected: Int, actual: Int) extends Exception with Product with Serializable

    Exception which represents too many rows returned.

  74. class Tx extends AnyRef

    DB Transaction abstraction.

  75. trait TypeBinder [+A] extends AnyRef

    Type binder for java.

  76. class UnexpectedNullValueException extends Exception

  77. class UnixTimeInMillisConverter extends AnyRef

    Unix Time Converter to several types.

  78. trait WithExtractor extends AnyRef

    Represents an extractor is already specified or not

  79. case class WrappedResultSet (underlying: ResultSet, cursor: ResultSetCursor, index: Int) extends Product with Serializable

    java.

Value Members

  1. object AutoSession extends DBSession with Product with Serializable

    Represents that already existing session will be used or a new session will be started.

  2. object CommonsConnectionPoolFactory extends ConnectionPoolFactory

    Connection Pool Factory

  3. object ConnectionPool extends LogSupport

    Connection Pool

  4. object DB extends Serializable

    Basic Database Accessor

  5. object DBSession extends AnyRef

  6. object GeneralizedTypeConstraintsForWithExtractor extends AnyRef

    Generalized type constraints for WithExtractor

  7. object GlobalSettings extends AnyRef

    GlobalSettings for this library

  8. object JDBCUrl extends Serializable

    Companion object of JDBC URL

  9. object LoanPattern extends AnyRef

    Loan pattern implementation

  10. object NoConnectionPoolContext extends ConnectionPoolContext

    No Connection Pool Context

  11. object NoSession extends DBSession with Product with Serializable

    Represents that there is no active session.

  12. object OneToXSQL extends AnyRef

  13. object ReadOnlyAutoSession extends DBSession with Product with Serializable

    Represents that already existing session will be used or a new read-only session will be started.

  14. object SQL extends AnyRef

    SQL abstraction's companion object.

  15. object SQLFormatterSettings extends Serializable

  16. object SQLTemplateParser extends JavaTokenParsers with LogSupport

    SQL Template Parser.

  17. object StatementExecutor extends Serializable

    Companion object.

  18. object StringSQLRunner extends Serializable

  19. object ThreadLocalDB extends AnyRef

    Thread-local DB.

  20. object TypeBinder extends LowPriorityTypeBinderImplicits

    Type binder for java.

  21. implicit def convertBigDecimal (bd: BigDecimal): ScalaBigDecimalConverter

    Attributes
    implicit
    Definition Classes
    package
  22. implicit def convertJavaSqlDateToConverter (t: Date): UnixTimeInMillisConverter

    Attributes
    implicit
    Definition Classes
    package
  23. implicit def convertJavaSqlTimeToConverter (t: Time): UnixTimeInMillisConverter

    Attributes
    implicit
    Definition Classes
    package
  24. implicit def convertJavaSqlTimestampToConverter (t: Timestamp): UnixTimeInMillisConverter

    Attributes
    implicit
    Definition Classes
    package
  25. implicit def convertJavaUtilDateToConverter (t: Date): UnixTimeInMillisConverter

    Attributes
    implicit
    Definition Classes
    package
  26. implicit def convertLocalTimeToConverter (t: LocalTime): LocalTimeConverter

    Attributes
    implicit
    Definition Classes
    package
  27. package globalsettings

  28. package metadata

  29. def opt [A] (v: Any): Option[A]

    Option value converter.

    Option value converter.

    A

    raw type

    v

    nullable raw value

    returns

    optional value

    Definition Classes
    package
  30. def using [R <: Closable, A] (resource: R)(f: (R) ⇒ A): A

    Definition Classes
    package

Deprecated Value Members

  1. val ExecutableSQLParser : scalikejdbc.SQLTemplateParser.type

    Definition Classes
    package
    Annotations
    @deprecated
    Deprecated

    ExecutableSQLParser renamed ifself SQLTemplateParser