ActiveSession

scalikejdbc.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 parameters

conn

connection

isReadOnly

is read only

tx

transaction

Attributes

Source
DBSession.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait DBSession
trait AutoCloseable
trait LoanPattern
class Object
trait Matchable
class Any
Show all

Members list

Type members

Inherited types

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

Attributes

Inherited from:
LoanPattern
Source
LoanPattern.scala

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 parameters

paramsList

list of parameters

template

SQL template

Attributes

Returns

count list

Inherited from:
DBSession
Source
DBSession.scala
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 parameters

paramsList

list of parameters

template

SQL template

Attributes

Returns

generated keys

Inherited from:
DBSession
Source
DBSession.scala
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 parameters

key

generated key name

paramsList

list of parameters

template

SQL template

Attributes

Returns

generated keys

Inherited from:
DBSession
Source
DBSession.scala
def close(): Unit

Close the connection.

Close the connection.

Attributes

Inherited from:
DBSession
Source
DBSession.scala
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 parameters

A

return type

C

return collection type

Value parameters

extract

extract function

params

parameters

template

SQL template

Attributes

Returns

result as C[A]

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

Executes java.sql.PreparedStatement#execute().

Executes java.sql.PreparedStatement#execute().

Value parameters

params

parameters

template

SQL template

Attributes

Returns

flag

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

Executes java.sql.PreparedStatement#executeLargeUpdate().

Executes java.sql.PreparedStatement#executeLargeUpdate().

Value parameters

params

parameters

template

SQL template

Attributes

Returns

result count

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

Executes java.sql.PreparedStatement#executeUpdate().

Executes java.sql.PreparedStatement#executeUpdate().

Value parameters

params

parameters

template

SQL template

Attributes

Returns

result count

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

Executes java.sql.PreparedStatement#execute().

Executes java.sql.PreparedStatement#execute().

Value parameters

after

after filter

before

before filter

params

parameters

template

SQL template

Attributes

Returns

flag

Inherited from:
DBSession
Source
DBSession.scala
def fetchSize: Option[Int]

Returns fetchSize for this session.

Returns fetchSize for this session.

Attributes

Returns

fetch size

Inherited from:
DBSession
Source
DBSession.scala
def fetchSize(fetchSize: Option[Int]): DBSession.this.type

Attributes

Inherited from:
DBSession
Source
DBSession.scala
def fetchSize(fetchSize: Int): DBSession.this.type

Set fetchSize for this session.

Set fetchSize for this session.

Value parameters

fetchSize

fetch size

Attributes

Returns

this

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

Returns the first row optionally.

Returns the first row optionally.

Type parameters

A

return type

Value parameters

extract

extract function

params

parameters

template

SQL template

Attributes

Returns

result optionally

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

folding into one value.

folding into one value.

Value parameters

op

function

params

parameters

template

SQL template

z

initial value

Attributes

Returns

folded value

Inherited from:
DBSession
Source
DBSession.scala
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 parameters

f

function

params

parameters

template

SQL template

Attributes

Returns

result as list

Inherited from:
DBSession
Source
DBSession.scala
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.

Attributes

Inherited from:
LoanPattern
Source
LoanPattern.scala
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 parameters

A

return type

Value parameters

extract

extract function

params

parameters

template

SQL template

Attributes

Returns

result as iterable

Inherited from:
DBSession
Source
DBSession.scala
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 parameters

paramsList

list of parameters

template

SQL template

Attributes

Returns

count list

Inherited from:
DBSession
Source
DBSession.scala
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 parameters

after

after filter

before

before filter

generatedKeyName

generated key name

params

parameters

returnGeneratedKeys

is generated keys required

template

SQL template

Attributes

Returns

result count

Inherited from:
DBSession
Source
DBSession.scala
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 parameters

after

after filter

before

before filter

params

parameters

returnGeneratedKeys

is generated keys required

template

SQL template

Attributes

Returns

result count

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

Executes java.sql.PreparedStatement#executeLargeUpdate().

Executes java.sql.PreparedStatement#executeLargeUpdate().

Value parameters

after

after filter

before

before filter

params

parameters

template

SQL template

Attributes

Returns

result count

Inherited from:
DBSession
Source
DBSession.scala
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 parameters

A

return type

Value parameters

extract

extract function

params

parameters

template

SQL template

Attributes

Returns

result as list

Inherited from:
DBSession
Source
DBSession.scala
def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product
def queryTimeout: Option[Int]

Returns queryTimeout for this session.

Returns queryTimeout for this session.

Attributes

Returns

query timeout seconds

Inherited from:
DBSession
Source
DBSession.scala
def queryTimeout(seconds: Option[Int]): DBSession.this.type

Attributes

Inherited from:
DBSession
Source
DBSession.scala
def queryTimeout(seconds: Int): DBSession.this.type

Set queryTimeout to this session.

Set queryTimeout to this session.

Value parameters

seconds

query timeout seconds

Attributes

Returns

this

Inherited from:
DBSession
Source
DBSession.scala
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 parameters

A

return type

Value parameters

extract

extract function

params

parameters

template

SQL template

Attributes

Returns

result optionally

Inherited from:
DBSession
Source
DBSession.scala
def tags: Seq[String]

Returns tags for this session.

Returns tags for this session.

Attributes

Returns

tags

Inherited from:
DBSession
Source
DBSession.scala
def tags(tags: String*): DBSession.this.type

Set tags to this session.

Set tags to this session.

Value parameters

tags

tags

Attributes

Returns

this

Inherited from:
DBSession
Source
DBSession.scala

Attributes

Inherited from:
DBSession
Source
DBSession.scala
def toStatementExecutor(template: String, params: Seq[Any], returnGeneratedKeys: Boolean): StatementExecutor

Attributes

Inherited from:
DBSession
Source
DBSession.scala
def update(template: String, params: Any*): Int

Executes java.sql.PreparedStatement#executeUpdate().

Executes java.sql.PreparedStatement#executeUpdate().

Value parameters

params

parameters

template

SQL template

Attributes

Returns

result count

Inherited from:
DBSession
Source
DBSession.scala
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 parameters

params

parameters

template

SQL template

Attributes

Returns

generated key as a long value

Inherited from:
DBSession
Source
DBSession.scala
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 parameters

key

name

params

parameters

template

SQL template

Attributes

Returns

generated key as a long value

Inherited from:
DBSession
Source
DBSession.scala
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 parameters

after

after filter

before

before filter

generatedKeyName

generated key name

params

parameters

returnGeneratedKeys

is generated keys required

template

SQL template

Attributes

Returns

result count

Inherited from:
DBSession
Source
DBSession.scala
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 parameters

after

after filter

before

before filter

params

parameters

returnGeneratedKeys

is generated keys required

template

SQL template

Attributes

Returns

result count

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

Executes java.sql.PreparedStatement#executeUpdate().

Executes java.sql.PreparedStatement#executeUpdate().

Value parameters

after

after filter

before

before filter

params

parameters

template

SQL template

Attributes

Returns

result count

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

Attributes

Inherited from:
LoanPattern
Source
LoanPattern.scala

Inherited fields

lazy val connection: Connection

Connection

Connection

Attributes

Inherited from:
DBSession
Source
DBSession.scala
protected val log: Log

Logger

Logger

Attributes

Inherited from:
LogSupport (hidden)
Source
LogSupport.scala