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")
Returns handler that delegates query execution to h
function.
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 { e: 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 } }
Returns handler that delegates update execution to h
function.
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 { e: 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 } }