|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.skife.jdbi.unstable.decorator.BaseHandleDecorator
public class BaseHandleDecorator
Convenience class implementing Handle which delegates all
method calls to the Handle
instance passed
into its constructor. This is provided to allow
decorator instances to only override the bahavior of
things they need to.
Constructor Summary | |
---|---|
BaseHandleDecorator(Handle handle)
|
Method Summary | |
---|---|
Batch |
batch()
Create a new Batch instance which can be used to queue up and execute statements in a single batch. |
void |
begin()
start a transaction |
void |
clearStatementCache()
Clear this handle's cache of prepared statements. |
void |
close()
Close the connection |
void |
commit()
Commit transaction in progress |
void |
execute(java.lang.String sql)
Execute an sql statement which does not return any results. |
void |
execute(java.lang.String statement,
java.util.Collection args)
Execute an sql statement which does not return any results. |
void |
execute(java.lang.String statement,
java.util.Map args)
Execute an sql statement which does not return any results. |
void |
execute(java.lang.String statement,
java.lang.Object bean)
Execute a statement with named parameters pulling values from a JavaBean |
void |
execute(java.lang.String statement,
java.lang.Object[] args)
Execute an sql statement which does not return any results. |
java.util.Map |
first(java.lang.String statement)
Returns the first row matched by the query |
java.util.Map |
first(java.lang.String statement,
java.util.Collection params)
Returns the first row matched by the query |
java.util.Map |
first(java.lang.String statement,
java.util.Map args)
Returns the first row matched by the query |
java.util.Map |
first(java.lang.String statement,
java.lang.Object bean)
Returns the first row matched by the query |
java.util.Map |
first(java.lang.String statement,
java.lang.Object[] params)
Returns the first row matched by the query |
java.sql.Connection |
getConnection()
Obtain the JDBC connection used by this handle |
java.util.Map |
getGlobalParameters()
Obtain a map containing globally set named parameter values. |
void |
inTransaction(TransactionCallback callback)
Execute transactionCallback in a transaction, cleaning up
as necesary around it |
boolean |
isInTransaction()
Has a transaction been started? |
boolean |
isOpen()
Checks to make sure the connection is live |
void |
load(java.lang.String name)
Eagerly load a named query from the filesystem. |
void |
name(java.lang.String name,
java.lang.String sql)
Prepared a named sql statement |
PreparedBatch |
prepareBatch(java.lang.String statement)
Create a new PreparedBatch instance from arbitrary SQL or a named statement |
java.util.List |
query(java.lang.String query)
Retrieve a collection of map instances from a query. |
java.util.List |
query(java.lang.String statement,
java.util.Collection args)
Execute statement with positional arguments |
java.util.List |
query(java.lang.String statement,
java.util.Map args)
Execute query using name parameters of the form: select id, name from something where id = :something and the
key to the params map is "something" |
void |
query(java.lang.String statement,
java.util.Map args,
RowCallback callback)
Iterate (once) over a resultset in order calling the callback for each row processed |
java.util.List |
query(java.lang.String statement,
java.lang.Object param)
Execute statement with JavaBean mapped named parameter |
java.util.List |
query(java.lang.String statement,
java.lang.Object[] args)
Execute statement with positional arguments |
void |
query(java.lang.String statement,
java.lang.Object[] args,
RowCallback callback)
Iterate (once) over a resultset in order calling the callback for each row processed |
void |
query(java.lang.String statement,
RowCallback callback)
Iterate (once) over a resultset in order calling the callback for each row processed |
void |
rollback()
Rollback a transaction in progress |
void |
script(java.lang.String name)
Find and execute the sql script name . |
int |
update(java.lang.String statement)
Execute a statement of the form update foo set bar = foo_id |
int |
update(java.lang.String statement,
java.util.Collection args)
Execute a statement of the form update foo set bar = foo_id |
int |
update(java.lang.String statement,
java.util.Map args)
Execute a statement of the form update foo set bar = foo_id |
int |
update(java.lang.String statement,
java.lang.Object bean)
Execute an update with named parameters pulling values from a JavaBean |
int |
update(java.lang.String statement,
java.lang.Object[] args)
Execute a statement of the form update foo set bar = foo_id |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BaseHandleDecorator(Handle handle)
Method Detail |
---|
public java.sql.Connection getConnection()
Handle
getConnection
in interface Handle
public void begin() throws DBIException
Handle
begin
in interface Handle
DBIException
public void close()
Handle
close
in interface Handle
public void clearStatementCache()
Handle
clearStatementCache
in interface Handle
public void commit() throws DBIException
Handle
commit
in interface Handle
DBIException
public void rollback() throws DBIException
Handle
rollback
in interface Handle
DBIException
- if the rollback failspublic void inTransaction(TransactionCallback callback) throws DBIException
Handle
transactionCallback
in a transaction, cleaning up
as necesary around it
inTransaction
in interface Handle
DBIException
public boolean isInTransaction()
Handle
isInTransaction
in interface Handle
public void execute(java.lang.String sql) throws DBIException
Handle
execute
in interface Handle
sql
- insert/update/create/delete/call statement
DBIException
public void execute(java.lang.String statement, java.lang.Object[] args) throws DBIException
Handle
execute
in interface Handle
statement
- insert/update/create/delete/call statementargs
- positional arguments to be bound to statement
DBIException
public void execute(java.lang.String statement, java.util.Collection args) throws DBIException
Handle
execute
in interface Handle
statement
- insert/update/create/delete/call statementargs
- positional arguments to be bound to statement
DBIException
public void execute(java.lang.String statement, java.util.Map args) throws DBIException
Handle
execute
in interface Handle
statement
- insert/update/create/delete/call statementargs
- named arguments to be bound to statement
DBIException
public void execute(java.lang.String statement, java.lang.Object bean) throws DBIException
Handle
execute
in interface Handle
statement
- SQL statement with named parametersbean
- JavaBean with properties to be de-referenced for named parameter substitution
DBIException
public int update(java.lang.String statement) throws DBIException
Handle
update foo set bar = foo_id
update
in interface Handle
statement
- sql statement or named statement
DBIException
- if anything goes wrongpublic int update(java.lang.String statement, java.lang.Object[] args) throws DBIException
Handle
update foo set bar = foo_id
update
in interface Handle
statement
- sql statement or named statementargs
- positional args to bind to statement
DBIException
- if anything goes wrongpublic int update(java.lang.String statement, java.util.Collection args) throws DBIException
Handle
update foo set bar = foo_id
update
in interface Handle
statement
- sql statement or named statementargs
- positional args to bind to statement
DBIException
- if anything goes wrongpublic int update(java.lang.String statement, java.util.Map args) throws DBIException
Handle
update foo set bar = foo_id
update
in interface Handle
statement
- sql statement or named statementargs
- named args to bind to statement
DBIException
- if anything goes wrongpublic int update(java.lang.String statement, java.lang.Object bean) throws DBIException
Handle
update
in interface Handle
statement
- sql named statement or direct sqlbean
- JavaBean whose properties
DBIException
public java.util.List query(java.lang.String query) throws DBIException
Handle
query
in interface Handle
query
- select statement
DBIException
public void query(java.lang.String statement, RowCallback callback) throws DBIException
Handle
query
in interface Handle
statement
- sql select statementcallback
- receive callbacks for each row in result
DBIException
public void query(java.lang.String statement, java.lang.Object[] args, RowCallback callback) throws DBIException
Handle
query
in interface Handle
statement
- sql select statementargs
- position arguments to the statementcallback
- receive callbacks for each row in result
DBIException
public void query(java.lang.String statement, java.util.Map args, RowCallback callback) throws DBIException
Handle
Named parameters are matched via \s+(:\w+)
outside of quotes,
so basically :id
, :foo_id
, or :id1
type
constructions.
query
in interface Handle
statement
- sql select statementargs
- named arguments to the statementcallback
- receive callbacks for each row in result
DBIException
public java.util.List query(java.lang.String statement, java.util.Map args) throws DBIException
Handle
select id, name from something where id = :something
and the
key to the params map is "something"
Named parameters are matched via \s+(:\w+)
outside of quotes,
so basically :id
, :foo_id
, or :id1
type
constructions.
query
in interface Handle
statement
- sql statementargs
- map of named parameters
DBIException
public java.util.List query(java.lang.String statement, java.lang.Object param) throws DBIException
Handle
query
in interface Handle
statement
- sql or named statement with named paramatersparam
- JavaBean whose properties will be used to populate named parameters
DBIException
public java.util.List query(java.lang.String statement, java.lang.Object[] args) throws DBIException
Handle
query
in interface Handle
statement
- sql or named statementargs
- positional parameters
DBIException
public java.util.List query(java.lang.String statement, java.util.Collection args) throws DBIException
Handle
query
in interface Handle
statement
- sql or named statementargs
- positional parameters, bound in iteration order
DBIException
public java.util.Map first(java.lang.String statement) throws DBIException
Handle
first
in interface Handle
statement
- select statement or named query
DBIException
public java.util.Map first(java.lang.String statement, java.lang.Object bean) throws DBIException
Handle
first
in interface Handle
statement
- select statement or named querybean
- JavaBean whose properties will be used to populate named parameters
DBIException
public java.util.Map first(java.lang.String statement, java.util.Map args) throws DBIException
Handle
first
in interface Handle
statement
- select statement or named queryargs
- map of named parameters
DBIException
public java.util.Map first(java.lang.String statement, java.lang.Object[] params) throws DBIException
Handle
first
in interface Handle
statement
- select statement or named queryparams
- positional parameters
DBIException
public java.util.Map first(java.lang.String statement, java.util.Collection params) throws DBIException
Handle
first
in interface Handle
statement
- select statement or named queryparams
- positional parameters
DBIException
public boolean isOpen() throws DBIException
Handle
isOpen
in interface Handle
DBIException
public void script(java.lang.String name) throws DBIException, java.io.IOException
Handle
name
. First it will be search for
name.sql
, or, if that is not found, name
will be loaded
directly.
Scripts should seperate statements with a semicolon, for example:
create table wombats (
wombat_id integer primary key,
name varchar(50)
);
insert into wombats (wombat_id, name) values (1, 'Muggie');
call wiggles(1, 2, 3);
script
in interface Handle
DBIException
java.io.IOException
public void name(java.lang.String name, java.lang.String sql) throws DBIException
Handle
name
in interface Handle
name
- name to issue query undersql
- sql string to use as query
DBIException
- if there is a problem preparing the statementpublic void load(java.lang.String name) throws java.io.IOException, DBIException
Handle
name
and it will look for a file named [name].sql
in the classpath which
contains a single sql statement.
load
in interface Handle
name
- name of query to load, such as "foo" which will be store din foo.sql
java.io.IOException
DBIException
public Batch batch()
Handle
batch
in interface Handle
public PreparedBatch prepareBatch(java.lang.String statement)
Handle
prepareBatch
in interface Handle
public java.util.Map getGlobalParameters()
Handle
Handles create a local copy of global parameters specified on the DBI instance used to create the handle. Global parameters added to the Handle will not be added to the DBI instance's globals, however.
getGlobalParameters
in interface Handle
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |