ActiveSession

case class ActiveSession(conn: Connection, connectionAttributes: DBConnectionAttributes, tx: Option[Tx], isReadOnly: Boolean, settings: SettingsProvider) extends DBSession

Active session implementation of scalikejdbc.DBSession.

This class provides readOnly/autoCommit/localTx/withinTx blocks and session objects.

import scalikejdbc._

val userIdList = DB autoCommit { session: DBSession =>
 session.list("select * from user") { rs => rs.int("id") }
}
Value Params
conn

connection

isReadOnly

is read only

tx

transaction

trait Serializable
trait Product
trait Equals
trait DBSession
trait AutoCloseable
trait LogSupport
class Object
trait Matchable
class Any

Type members

Inherited types

type Closable = { def close(): Unit; }
Inherited from
LoanPattern

Value members

Inherited methods

def batch[C[_]](template: String, paramsList: Seq[Any]*)(implicit f: Factory[Int, C[Int]]): C[Int]

Executes java.sql.PreparedStatement#executeBatch().

Executes java.sql.PreparedStatement#executeBatch().

Value Params
paramsList

list of parameters

template

SQL template

Returns

count list

Inherited from
DBSession
def batchAndReturnGeneratedKey[C[_]](template: String, paramsList: Seq[Any]*)(implicit f: Factory[Long, C[Long]]): C[Long]

Executes java.sql.PreparedStatement#executeBatch() and returns numeric generated keys.

Executes java.sql.PreparedStatement#executeBatch() and returns numeric generated keys.

Value Params
paramsList

list of parameters

template

SQL template

Returns

generated keys

Inherited from
DBSession
def batchAndReturnSpecifiedGeneratedKey[C[_]](template: String, key: String, paramsList: Seq[Any]*)(implicit f: Factory[Long, C[Long]]): C[Long]

Executes java.sql.PreparedStatement#executeBatch() and returns numeric generated keys.

Executes java.sql.PreparedStatement#executeBatch() and returns numeric generated keys.

Value Params
key

generated key name

paramsList

list of parameters

template

SQL template

Returns

generated keys

Inherited from
DBSession
def close(): Unit

Close the connection.

Close the connection.

Inherited from
DBSession
def collection[A, C[_]](template: String, params: Any*)(extract: WrappedResultSet => A)(implicit f: Factory[A, C[A]]): C[A]

Returns query result as any Collection object.

Returns query result as any Collection object.

Type Params
A

return type

C

return collection type

Value Params
extract

extract function

params

parameters

template

SQL template

Returns

result as C[A]

Inherited from
DBSession
def execute(template: String, params: Any*): Boolean

Executes java.sql.PreparedStatement#execute().

Executes java.sql.PreparedStatement#execute().

Value Params
params

parameters

template

SQL template

Returns

flag

Inherited from
DBSession
def executeLargeUpdate(template: String, params: Any*): Long

Executes java.sql.PreparedStatement#executeLargeUpdate().

Executes java.sql.PreparedStatement#executeLargeUpdate().

Value Params
params

parameters

template

SQL template

Returns

result count

Inherited from
DBSession
def executeUpdate(template: String, params: Any*): Int

Executes java.sql.PreparedStatement#executeUpdate().

Executes java.sql.PreparedStatement#executeUpdate().

Value Params
params

parameters

template

SQL template

Returns

result count

Inherited from
DBSession
def executeWithFilters(before: PreparedStatement => Unit, after: PreparedStatement => Unit, template: String, params: Any*): Boolean

Executes java.sql.PreparedStatement#execute().

Executes java.sql.PreparedStatement#execute().

Value Params
after

after filter

before

before filter

params

parameters

template

SQL template

Returns

flag

Inherited from
DBSession
def fetchSize: Option[Int]

Returns fetchSize for this session.

Returns fetchSize for this session.

Returns

fetch size

Inherited from
DBSession
def fetchSize(fetchSize: Option[Int]): ActiveSession
Inherited from
DBSession
def fetchSize(fetchSize: Int): ActiveSession

Set fetchSize for this session.

Set fetchSize for this session.

Value Params
fetchSize

fetch size

Returns

this

Inherited from
DBSession
def first[A](template: String, params: Any*)(extract: WrappedResultSet => A): Option[A]

Returns the first row optionally.

Returns the first row optionally.

Type Params
A

return type

Value Params
extract

extract function

params

parameters

template

SQL template

Returns

result optionally

Inherited from
DBSession
def foldLeft[A](template: String, params: Any*)(z: A)(op: (A, WrappedResultSet) => A): A

folding into one value.

folding into one value.

Value Params
op

function

params

parameters

template

SQL template

z

initial value

Returns

folded value

Inherited from
DBSession
def foreach(template: String, params: Any*)(f: WrappedResultSet => Unit): Unit

Applies side-effect to each row iteratively.

Applies side-effect to each row iteratively.

Value Params
f

function

params

parameters

template

SQL template

Returns

result as list

Inherited from
DBSession
def futureUsing[R <: Closable, A](resource: R)(f: R => Future[A])(implicit ec: ExecutionContext): Future[A]

Guarantees a Closeable resource will be closed after being passed to a block that takes the resource as a parameter and returns a Future.

Guarantees a Closeable resource will be closed after being passed to a block that takes the resource as a parameter and returns a Future.

Inherited from
LoanPattern
def iterable[A](template: String, params: Any*)(extract: WrappedResultSet => A): Iterable[A]

Returns query result as scala.collection.Iterable object.

Returns query result as scala.collection.Iterable object.

Type Params
A

return type

Value Params
extract

extract function

params

parameters

template

SQL template

Returns

result as iterable

Inherited from
DBSession
def largeBatch[C[_]](template: String, paramsList: Seq[Any]*)(implicit f: Factory[Long, C[Long]]): C[Long]

Executes java.sql.PreparedStatement#executeLargeBatch().

Executes java.sql.PreparedStatement#executeLargeBatch().

Value Params
paramsList

list of parameters

template

SQL template

Returns

count list

Inherited from
DBSession
def largeUpdateWithAutoGeneratedKeyNameAndFilters(returnGeneratedKeys: Boolean, generatedKeyName: String, before: PreparedStatement => Unit, after: PreparedStatement => Unit, template: String, params: Any*): Long

Executes java.sql.PreparedStatement#executeLargeUpdate().

Executes java.sql.PreparedStatement#executeLargeUpdate().

Value Params
after

after filter

before

before filter

generatedKeyName

generated key name

params

parameters

returnGeneratedKeys

is generated keys required

template

SQL template

Returns

result count

Inherited from
DBSession
def largeUpdateWithFilters(returnGeneratedKeys: Boolean, before: PreparedStatement => Unit, after: PreparedStatement => Unit, template: String, params: Any*): Long

Executes java.sql.PreparedStatement#executeLargeUpdate().

Executes java.sql.PreparedStatement#executeLargeUpdate().

Value Params
after

after filter

before

before filter

params

parameters

returnGeneratedKeys

is generated keys required

template

SQL template

Returns

result count

Inherited from
DBSession
def largeUpdateWithFilters(before: PreparedStatement => Unit, after: PreparedStatement => Unit, template: String, params: Any*): Long

Executes java.sql.PreparedStatement#executeLargeUpdate().

Executes java.sql.PreparedStatement#executeLargeUpdate().

Value Params
after

after filter

before

before filter

params

parameters

template

SQL template

Returns

result count

Inherited from
DBSession
def list[A](template: String, params: Any*)(extract: WrappedResultSet => A): List[A]

Returns query result as scala.List object.

Returns query result as scala.List object.

Type Params
A

return type

Value Params
extract

extract function

params

parameters

template

SQL template

Returns

result as list

Inherited from
DBSession
def productElementNames: Iterator[String]
Inherited from
Product
def productIterator: Iterator[Any]
Inherited from
Product
def queryTimeout: Option[Int]

Returns queryTimeout for this session.

Returns queryTimeout for this session.

Returns

query timeout seconds

Inherited from
DBSession
def queryTimeout(seconds: Option[Int]): ActiveSession
Inherited from
DBSession
def queryTimeout(seconds: Int): ActiveSession

Set queryTimeout to this session.

Set queryTimeout to this session.

Value Params
seconds

query timeout seconds

Returns

this

Inherited from
DBSession
def single[A](template: String, params: Any*)(extract: WrappedResultSet => A): Option[A]

Returns single result optionally. If the result is not single, scalikejdbc.TooManyRowsException will be thrown.

Returns single result optionally. If the result is not single, scalikejdbc.TooManyRowsException will be thrown.

Type Params
A

return type

Value Params
extract

extract function

params

parameters

template

SQL template

Returns

result optionally

Inherited from
DBSession
def tags: Seq[String]

Returns tags for this session.

Returns tags for this session.

Returns

tags

Inherited from
DBSession
def tags(tags: String*): ActiveSession

Set tags to this session.

Set tags to this session.

Value Params
tags

tags

Returns

this

Inherited from
DBSession
Inherited from
DBSession
def toStatementExecutor(template: String, params: Seq[Any], returnGeneratedKeys: Boolean): StatementExecutor
Inherited from
DBSession
def update(template: String, params: Any*): Int

Executes java.sql.PreparedStatement#executeUpdate().

Executes java.sql.PreparedStatement#executeUpdate().

Value Params
params

parameters

template

SQL template

Returns

result count

Inherited from
DBSession
def updateAndReturnGeneratedKey(template: String, params: Any*): Long

Executes java.sql.PreparedStatement#executeUpdate() and returns the generated key.

Executes java.sql.PreparedStatement#executeUpdate() and returns the generated key.

Value Params
params

parameters

template

SQL template

Returns

generated key as a long value

Inherited from
DBSession
def updateAndReturnSpecifiedGeneratedKey(template: String, params: Any*)(key: Any): Long

Executes java.sql.PreparedStatement#executeUpdate() and returns the generated key.

Executes java.sql.PreparedStatement#executeUpdate() and returns the generated key.

Value Params
key

name

params

parameters

template

SQL template

Returns

generated key as a long value

Inherited from
DBSession
def updateWithAutoGeneratedKeyNameAndFilters(returnGeneratedKeys: Boolean, generatedKeyName: String, before: PreparedStatement => Unit, after: PreparedStatement => Unit, template: String, params: Any*): Int

Executes java.sql.PreparedStatement#executeUpdate().

Executes java.sql.PreparedStatement#executeUpdate().

Value Params
after

after filter

before

before filter

generatedKeyName

generated key name

params

parameters

returnGeneratedKeys

is generated keys required

template

SQL template

Returns

result count

Inherited from
DBSession
def updateWithFilters(returnGeneratedKeys: Boolean, before: PreparedStatement => Unit, after: PreparedStatement => Unit, template: String, params: Any*): Int

Executes java.sql.PreparedStatement#executeUpdate().

Executes java.sql.PreparedStatement#executeUpdate().

Value Params
after

after filter

before

before filter

params

parameters

returnGeneratedKeys

is generated keys required

template

SQL template

Returns

result count

Inherited from
DBSession
def updateWithFilters(before: PreparedStatement => Unit, after: PreparedStatement => Unit, template: String, params: Any*): Int

Executes java.sql.PreparedStatement#executeUpdate().

Executes java.sql.PreparedStatement#executeUpdate().

Value Params
after

after filter

before

before filter

params

parameters

template

SQL template

Returns

result count

Inherited from
DBSession
def using[R <: Closable, A](resource: R)(f: R => A): A
Inherited from
LoanPattern

Inherited fields

lazy val connection: Connection

Connection

Connection

Inherited from
DBSession
protected val log: Log

Logger

Logger

Inherited from
LogSupport