ScalaCompositeHandler

acolyte.jdbc.ScalaCompositeHandler
final class ScalaCompositeHandler(qd: Array[Pattern], qh: QueryHandler, uh: UpdateHandler) extends AbstractCompositeHandler[ScalaCompositeHandler]

Attributes

Graph
Supertypes
class AbstractCompositeHandler[ScalaCompositeHandler]
trait StatementHandler
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Concrete methods

Returns handler that detects statement matching given pattern(s) as query.

Returns handler that detects statement matching given pattern(s) as query.

import acolyte.jdbc.AcolyteDSL.handleStatement

// Created handle will detect as query statements
// either starting with 'SELECT ' or containing 'EXEC proc'.
handleStatement.withQueryDetection("^SELECT ", "EXEC proc")

Attributes

Returns handler that delegates query execution to h function. Given function will be used only if executed statement is detected as a query by withQueryDetection.

Returns handler that delegates query execution to h function. Given function will be used only if executed statement is detected as a query by withQueryDetection.

import acolyte.jdbc.{ QueryExecution, QueryResult }
import acolyte.jdbc.AcolyteDSL.handleStatement

import acolyte.jdbc.Implicits.stringAsResult
def aQueryResult: QueryResult = "lorem"

handleStatement withQueryHandler { (_: QueryExecution) => aQueryResult }

// With pattern matching ...
import acolyte.jdbc.{ ExecutedParameter => P }

def foo(otherResult: QueryResult) =
 handleStatement withQueryHandler {
   _ match {
     case QueryExecution(
       "SELECT * FROM Test WHERE id = ?", P(1) :: Nil) =>
       aQueryResult

     case _ => otherResult
   }
 }

Attributes

Returns handler that delegates update execution to h function. Given function will be used only if executed statement is not detected as a query by withQueryDetection.

Returns handler that delegates update execution to h function. Given function will be used only if executed statement is not detected as a query by withQueryDetection.

import acolyte.jdbc.{ UpdateResult, UpdateExecution }
import acolyte.jdbc.AcolyteDSL.handleStatement
import acolyte.jdbc.Implicits._

val aUpResult: UpdateResult = 1

handleStatement withUpdateHandler { (_: UpdateExecution) => aUpResult }

// With pattern matching ...
import acolyte.jdbc.{ ExecutedParameter => P }

def bar(otherResult: UpdateResult) = handleStatement withUpdateHandler {
 _ match {
   case UpdateExecution(
     "INSERT INTO Country (code, name) VALUES (?, ?)",
     P(_/*code*/) :: P(_/*name*/) :: Nil) => 1 // update count

   case _ => otherResult
 }
}

Attributes

Inherited methods

def isQuery(x$0: String): Boolean

Attributes

Inherited from:
AbstractCompositeHandler
def whenSQLQuery(x$0: String, x$1: List[Parameter]): QueryResult

Attributes

Inherited from:
AbstractCompositeHandler
def whenSQLUpdate(x$0: String, x$1: List[Parameter]): UpdateResult

Attributes

Inherited from:
AbstractCompositeHandler
def withQueryDetection(x$0: String*): T

Attributes

Inherited from:
AbstractCompositeHandler