case class ActiveSession(conn: Connection, connectionAttributes: DBConnectionAttributes, tx: Option[Tx] = None, isReadOnly: Boolean = false, settings: SettingsProvider = SettingsProvider.default) extends DBSession with Product with Serializable
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") } }
- conn
connection
- tx
transaction
- isReadOnly
is read only
- Source
- DBSession.scala
- Alphabetic
- By Inheritance
- ActiveSession
- Serializable
- Serializable
- Product
- Equals
- DBSession
- AutoCloseable
- LoanPattern
- LogSupport
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
ActiveSession(conn: Connection, connectionAttributes: DBConnectionAttributes, tx: Option[Tx] = None, isReadOnly: Boolean = false, settings: SettingsProvider = SettingsProvider.default)
- conn
connection
- tx
transaction
- isReadOnly
is read only
Type Members
-
type
Closable = AnyRef { def close(): Unit }
- Definition Classes
- LoanPattern
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
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
batch[C[_]](template: String, paramsList: Seq[Any]*)(implicit cbf: CanBuildFrom[Nothing, Int, C[Int]]): C[Int]
Executes java.sql.PreparedStatement#executeBatch().
Executes java.sql.PreparedStatement#executeBatch().
- template
SQL template
- paramsList
list of parameters
- returns
count list
- Definition Classes
- DBSession
-
def
batchAndReturnGeneratedKey[C[_]](template: String, paramsList: Seq[Any]*)(implicit cbf: CanBuildFrom[Nothing, 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.
- template
SQL template
- paramsList
list of parameters
- returns
generated keys
- Definition Classes
- DBSession
-
def
batchAndReturnSpecifiedGeneratedKey[C[_]](template: String, key: String, paramsList: Seq[Any]*)(implicit cbf: CanBuildFrom[Nothing, 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.
- template
SQL template
- key
generated key name
- paramsList
list of parameters
- returns
generated keys
- Definition Classes
- DBSession
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
close(): Unit
Close the connection.
Close the connection.
- Definition Classes
- DBSession → AutoCloseable
-
def
collection[A, C[_]](template: String, params: Any*)(extract: (WrappedResultSet) ⇒ A)(implicit cbf: CanBuildFrom[Nothing, A, C[A]]): C[A]
Returns query result as any Collection object.
Returns query result as any Collection object.
- A
return type
- C
return collection type
- template
SQL template
- params
parameters
- extract
extract function
- returns
result as C[A]
- Definition Classes
- DBSession
-
lazy val
connection: Connection
Connection
Connection
- Definition Classes
- DBSession
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
execute(template: String, params: Any*): Boolean
Executes java.sql.PreparedStatement#execute().
Executes java.sql.PreparedStatement#execute().
- template
SQL template
- params
parameters
- returns
flag
- Definition Classes
- DBSession
-
def
executeLargeUpdate(template: String, params: Any*): Long
Executes java.sql.PreparedStatement#executeLargeUpdate().
Executes java.sql.PreparedStatement#executeLargeUpdate().
- template
SQL template
- params
parameters
- returns
result count
- Definition Classes
- DBSession
-
def
executeUpdate(template: String, params: Any*): Int
Executes java.sql.PreparedStatement#executeUpdate().
Executes java.sql.PreparedStatement#executeUpdate().
- template
SQL template
- params
parameters
- returns
result count
- Definition Classes
- DBSession
-
def
executeWithFilters(before: (PreparedStatement) ⇒ Unit, after: (PreparedStatement) ⇒ Unit, template: String, params: Any*): Boolean
Executes java.sql.PreparedStatement#execute().
Executes java.sql.PreparedStatement#execute().
- before
before filter
- after
after filter
- template
SQL template
- params
parameters
- returns
flag
- Definition Classes
- DBSession
-
def
fetchSize: Option[Int]
Returns fetchSize for this session.
-
def
fetchSize(fetchSize: Option[Int]): ActiveSession.this.type
- Definition Classes
- DBSession
-
def
fetchSize(fetchSize: Int): ActiveSession.this.type
Set fetchSize for this session.
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
first[A](template: String, params: Any*)(extract: (WrappedResultSet) ⇒ A): Option[A]
Returns the first row optionally.
Returns the first row optionally.
- A
return type
- template
SQL template
- params
parameters
- extract
extract function
- returns
result optionally
- Definition Classes
- DBSession
-
def
foldLeft[A](template: String, params: Any*)(z: A)(op: (A, WrappedResultSet) ⇒ A): A
folding into one value.
folding into one value.
- template
SQL template
- params
parameters
- z
initial value
- op
function
- returns
folded value
- Definition Classes
- 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.
- template
SQL template
- params
parameters
- f
function
- returns
result as list
- Definition Classes
- 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.
- Definition Classes
- LoanPattern
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
val
isReadOnly: Boolean
is read-only session
is read-only session
- Definition Classes
- ActiveSession → DBSession
-
def
largeBatch[C[_]](template: String, paramsList: Seq[Any]*)(implicit cbf: CanBuildFrom[Nothing, Long, C[Long]]): C[Long]
Executes java.sql.PreparedStatement#executeLargeBatch().
Executes java.sql.PreparedStatement#executeLargeBatch().
- template
SQL template
- paramsList
list of parameters
- returns
count list
- Definition Classes
- 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().
- returnGeneratedKeys
is generated keys required
- generatedKeyName
generated key name
- before
before filter
- after
after filter
- template
SQL template
- params
parameters
- returns
result count
- Definition Classes
- 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().
- returnGeneratedKeys
is generated keys required
- before
before filter
- after
after filter
- template
SQL template
- params
parameters
- returns
result count
- Definition Classes
- DBSession
-
def
largeUpdateWithFilters(before: (PreparedStatement) ⇒ Unit, after: (PreparedStatement) ⇒ Unit, template: String, params: Any*): Long
Executes java.sql.PreparedStatement#executeLargeUpdate().
Executes java.sql.PreparedStatement#executeLargeUpdate().
- before
before filter
- after
after filter
- template
SQL template
- params
parameters
- returns
result count
- Definition Classes
- 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.
- A
return type
- template
SQL template
- params
parameters
- extract
extract function
- returns
result as list
- Definition Classes
- DBSession
-
val
log: Log
Logger
Logger
- Attributes
- protected
- Definition Classes
- LogSupport
-
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
queryTimeout: Option[Int]
Returns queryTimeout for this session.
-
def
queryTimeout(seconds: Option[Int]): ActiveSession.this.type
- Definition Classes
- DBSession
-
def
queryTimeout(seconds: Int): ActiveSession.this.type
Set queryTimeout to this session.
Set queryTimeout to this session.
- seconds
query timeout seconds
- returns
this
- Definition Classes
- DBSession
-
val
settings: SettingsProvider
- Definition Classes
- ActiveSession → DBSession
-
def
single[A](template: String, params: Any*)(extract: (WrappedResultSet) ⇒ A): Option[A]
Returns single result optionally.
Returns single result optionally. If the result is not single, scalikejdbc.TooManyRowsException will be thrown.
- A
return type
- template
SQL template
- params
parameters
- extract
extract function
- returns
result optionally
- Definition Classes
- DBSession
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
tags: Seq[String]
Returns tags for this session.
-
def
tags(tags: String*): ActiveSession.this.type
Set tags to this session.
-
def
toBatchStatementExecutor(template: String): StatementExecutor
- Definition Classes
- DBSession
-
def
toStatementExecutor(template: String, params: Seq[Any], returnGeneratedKeys: Boolean = false): StatementExecutor
- Definition Classes
- DBSession
-
def
traversable[A](template: String, params: Any*)(extract: (WrappedResultSet) ⇒ A): Traversable[A]
Returns query result as scala.collection.Traversable object.
Returns query result as scala.collection.Traversable object.
- A
return type
- template
SQL template
- params
parameters
- extract
extract function
- returns
result as traversable
- Definition Classes
- DBSession
-
val
tx: Option[Tx]
Returns current transaction if exists.
Returns current transaction if exists.
- Definition Classes
- ActiveSession → DBSession
-
def
unexpectedInvocation[A]: A
- Attributes
- protected
- Definition Classes
- DBSession
-
def
update(template: String, params: Any*): Int
Executes java.sql.PreparedStatement#executeUpdate().
Executes java.sql.PreparedStatement#executeUpdate().
- template
SQL template
- params
parameters
- returns
result count
- Definition Classes
- 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.
- template
SQL template
- params
parameters
- returns
generated key as a long value
- Definition Classes
- 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.
- template
SQL template
- params
parameters
- key
name
- returns
generated key as a long value
- Definition Classes
- 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().
- returnGeneratedKeys
is generated keys required
- generatedKeyName
generated key name
- before
before filter
- after
after filter
- template
SQL template
- params
parameters
- returns
result count
- Definition Classes
- 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().
- returnGeneratedKeys
is generated keys required
- before
before filter
- after
after filter
- template
SQL template
- params
parameters
- returns
result count
- Definition Classes
- DBSession
-
def
updateWithFilters(before: (PreparedStatement) ⇒ Unit, after: (PreparedStatement) ⇒ Unit, template: String, params: Any*): Int
Executes java.sql.PreparedStatement#executeUpdate().
Executes java.sql.PreparedStatement#executeUpdate().
- before
before filter
- after
after filter
- template
SQL template
- params
parameters
- returns
result count
- Definition Classes
- DBSession
-
def
using[R <: Closable, A](resource: R)(f: (R) ⇒ A): A
- Definition Classes
- LoanPattern
-
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( ... )