public class DefaultSqlSession extends Object implements SqlSession
SqlSession.
Note that this class is not Thread-Safe.| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultSqlSession.StrictMap<V>
Deprecated.
Since 3.5.5
|
| Constructor and Description |
|---|
DefaultSqlSession(Configuration configuration,
Executor executor) |
DefaultSqlSession(Configuration configuration,
Executor executor,
boolean autoCommit) |
| Modifier and Type | Method and Description |
|---|---|
void |
clearCache()
Clears local session cache.
|
void |
close()
Closes the session.
|
void |
commit()
Flushes batch statements and commits database connection.
|
void |
commit(boolean force)
Flushes batch statements and commits database connection.
|
int |
delete(String statement)
Execute a delete statement.
|
int |
delete(String statement,
Object parameter)
Execute a delete statement.
|
List<BatchResult> |
flushStatements()
Flushes batch statements.
|
Configuration |
getConfiguration()
Retrieves current configuration.
|
Connection |
getConnection()
Retrieves inner database connection.
|
<T> T |
getMapper(Class<T> type)
Retrieves a mapper.
|
int |
insert(String statement)
Execute an insert statement.
|
int |
insert(String statement,
Object parameter)
Execute an insert statement with the given parameter object.
|
void |
rollback()
Discards pending batch statements and rolls database connection back.
|
void |
rollback(boolean force)
Discards pending batch statements and rolls database connection back.
|
void |
select(String statement,
Object parameter,
ResultHandler handler)
Retrieve a single row mapped from the statement key and parameter
using a
ResultHandler. |
void |
select(String statement,
Object parameter,
RowBounds rowBounds,
ResultHandler handler)
Retrieve a single row mapped from the statement key and parameter using a
ResultHandler and
RowBounds. |
void |
select(String statement,
ResultHandler handler)
Retrieve a single row mapped from the statement
using a
ResultHandler. |
<T> Cursor<T> |
selectCursor(String statement)
A Cursor offers the same results as a List, except it fetches data lazily using an Iterator.
|
<T> Cursor<T> |
selectCursor(String statement,
Object parameter)
A Cursor offers the same results as a List, except it fetches data lazily using an Iterator.
|
<T> Cursor<T> |
selectCursor(String statement,
Object parameter,
RowBounds rowBounds)
A Cursor offers the same results as a List, except it fetches data lazily using an Iterator.
|
<E> List<E> |
selectList(String statement)
Retrieve a list of mapped objects from the statement key.
|
<E> List<E> |
selectList(String statement,
Object parameter)
Retrieve a list of mapped objects from the statement key and parameter.
|
<E> List<E> |
selectList(String statement,
Object parameter,
RowBounds rowBounds)
Retrieve a list of mapped objects from the statement key and parameter,
within the specified row bounds.
|
<K,V> Map<K,V> |
selectMap(String statement,
Object parameter,
String mapKey)
The selectMap is a special case in that it is designed to convert a list
of results into a Map based on one of the properties in the resulting
objects.
|
<K,V> Map<K,V> |
selectMap(String statement,
Object parameter,
String mapKey,
RowBounds rowBounds)
The selectMap is a special case in that it is designed to convert a list
of results into a Map based on one of the properties in the resulting
objects.
|
<K,V> Map<K,V> |
selectMap(String statement,
String mapKey)
The selectMap is a special case in that it is designed to convert a list
of results into a Map based on one of the properties in the resulting
objects.
|
<T> T |
selectOne(String statement)
Retrieve a single row mapped from the statement key.
|
<T> T |
selectOne(String statement,
Object parameter)
Retrieve a single row mapped from the statement key and parameter.
|
int |
update(String statement)
Execute an update statement.
|
int |
update(String statement,
Object parameter)
Execute an update statement.
|
public DefaultSqlSession(Configuration configuration, Executor executor, boolean autoCommit)
public DefaultSqlSession(Configuration configuration, Executor executor)
public <T> T selectOne(String statement)
SqlSessionselectOne in interface SqlSessionT - the returned object typestatement - the statementpublic <T> T selectOne(String statement, Object parameter)
SqlSessionselectOne in interface SqlSessionT - the returned object typestatement - Unique identifier matching the statement to use.parameter - A parameter object to pass to the statement.public <K,V> Map<K,V> selectMap(String statement, String mapKey)
SqlSessionselectMap in interface SqlSessionK - the returned Map keys typeV - the returned Map values typestatement - Unique identifier matching the statement to use.mapKey - The property to use as key for each value in the list.public <K,V> Map<K,V> selectMap(String statement, Object parameter, String mapKey)
SqlSessionselectMap in interface SqlSessionK - the returned Map keys typeV - the returned Map values typestatement - Unique identifier matching the statement to use.parameter - A parameter object to pass to the statement.mapKey - The property to use as key for each value in the list.public <K,V> Map<K,V> selectMap(String statement, Object parameter, String mapKey, RowBounds rowBounds)
SqlSessionselectMap in interface SqlSessionK - the returned Map keys typeV - the returned Map values typestatement - Unique identifier matching the statement to use.parameter - A parameter object to pass to the statement.mapKey - The property to use as key for each value in the list.rowBounds - Bounds to limit object retrievalpublic <T> Cursor<T> selectCursor(String statement)
SqlSessionselectCursor in interface SqlSessionT - the returned cursor element type.statement - Unique identifier matching the statement to use.public <T> Cursor<T> selectCursor(String statement, Object parameter)
SqlSessionselectCursor in interface SqlSessionT - the returned cursor element type.statement - Unique identifier matching the statement to use.parameter - A parameter object to pass to the statement.public <T> Cursor<T> selectCursor(String statement, Object parameter, RowBounds rowBounds)
SqlSessionselectCursor in interface SqlSessionT - the returned cursor element type.statement - Unique identifier matching the statement to use.parameter - A parameter object to pass to the statement.rowBounds - Bounds to limit object retrievalpublic <E> List<E> selectList(String statement)
SqlSessionselectList in interface SqlSessionE - the returned list element typestatement - Unique identifier matching the statement to use.public <E> List<E> selectList(String statement, Object parameter)
SqlSessionselectList in interface SqlSessionE - the returned list element typestatement - Unique identifier matching the statement to use.parameter - A parameter object to pass to the statement.public <E> List<E> selectList(String statement, Object parameter, RowBounds rowBounds)
SqlSessionselectList in interface SqlSessionE - the returned list element typestatement - Unique identifier matching the statement to use.parameter - A parameter object to pass to the statement.rowBounds - Bounds to limit object retrievalpublic void select(String statement, Object parameter, ResultHandler handler)
SqlSessionResultHandler.select in interface SqlSessionstatement - Unique identifier matching the statement to use.parameter - A parameter object to pass to the statement.handler - ResultHandler that will handle each retrieved rowpublic void select(String statement, ResultHandler handler)
SqlSessionResultHandler.select in interface SqlSessionstatement - Unique identifier matching the statement to use.handler - ResultHandler that will handle each retrieved rowpublic void select(String statement, Object parameter, RowBounds rowBounds, ResultHandler handler)
SqlSessionResultHandler and
RowBounds.select in interface SqlSessionstatement - Unique identifier matching the statement to use.parameter - the parameterrowBounds - RowBound instance to limit the query resultshandler - ResultHandler that will handle each retrieved rowpublic int insert(String statement)
SqlSessioninsert in interface SqlSessionstatement - Unique identifier matching the statement to execute.public int insert(String statement, Object parameter)
SqlSessioninsert in interface SqlSessionstatement - Unique identifier matching the statement to execute.parameter - A parameter object to pass to the statement.public int update(String statement)
SqlSessionupdate in interface SqlSessionstatement - Unique identifier matching the statement to execute.public int update(String statement, Object parameter)
SqlSessionupdate in interface SqlSessionstatement - Unique identifier matching the statement to execute.parameter - A parameter object to pass to the statement.public int delete(String statement)
SqlSessiondelete in interface SqlSessionstatement - Unique identifier matching the statement to execute.public int delete(String statement, Object parameter)
SqlSessiondelete in interface SqlSessionstatement - Unique identifier matching the statement to execute.parameter - A parameter object to pass to the statement.public void commit()
SqlSessionSqlSession.commit(boolean)commit in interface SqlSessionpublic void commit(boolean force)
SqlSessioncommit in interface SqlSessionforce - forces connection commitpublic void rollback()
SqlSessionSqlSession.rollback(boolean)rollback in interface SqlSessionpublic void rollback(boolean force)
SqlSessionrollback in interface SqlSessionforce - forces connection rollbackpublic List<BatchResult> flushStatements()
SqlSessionflushStatements in interface SqlSessionpublic void close()
SqlSessionclose in interface Closeableclose in interface AutoCloseableclose in interface SqlSessionpublic Configuration getConfiguration()
SqlSessiongetConfiguration in interface SqlSessionpublic <T> T getMapper(Class<T> type)
SqlSessiongetMapper in interface SqlSessionT - the mapper typetype - Mapper interface classpublic Connection getConnection()
SqlSessiongetConnection in interface SqlSessionpublic void clearCache()
SqlSessionclearCache in interface SqlSessionCopyright © 2009–2021 MyBatis.org. All rights reserved.