public class SqlSession extends Object implements AutoCloseable
| Modifier and Type | Field and Description |
|---|---|
protected ClassCreator |
classCreator
Use to generate proxy on the dao
|
protected Connection |
connection
Current JDBC connection
|
protected DataSource |
dataSource
Current datasource
|
protected Class<? extends SpgeedMapper> |
defaultMapper
Use to set a default Mapper
|
protected String |
defaultTimeOutLimit
Use to set a default limit of time for PostgreSQL request
|
protected Map<String,PipeFunction> |
pipeFunctions
Current pipe functions available
|
| Constructor and Description |
|---|
SqlSession() |
SqlSession(DataSource dataSource)
Create session from a datasource
|
SqlSession(String url,
String username,
String password)
Create session from url, username and password
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFunction(Map<String,PipeFunction> functions) |
void |
addFunction(String name,
PipeFunction function) |
void |
close()
Close the current transaction.
|
void |
commit()
Commit the current transaction.
|
boolean |
execute(String sql,
Map<String,Object> parameters,
String... roles) |
<E> E |
executeQuery(String sql,
Map<String,Object> parameters,
Class<E> returnClass,
String... roles) |
int |
executeUpdate(String sql,
Map<String,Object> parameters,
String... roles) |
Connection |
getConnection()
Use to get the current transaction when the SQL statements is executed.
|
<E> E |
getDao(Class<E> klass,
Object... args)
Get a current dao plug on the session.
|
DataSource |
getDataSource() |
Class<? extends SpgeedMapper> |
getDefaultMapper()
Get the actual default mapper
|
String |
getDefaultTimeOutLimit()
Get the actual default limit of time for PostgreSQL request
|
Map<String,PipeFunction> |
getPipeFunctions() |
void |
rollback()
Rollback the current transaction.
|
void |
setDefaultMapper(Class<? extends SpgeedMapper> defaultMapper)
Set a default mapper
|
void |
setDefaultTimeOutLimit(String defaultTimeOutLimit)
Use to set a default limit of time for PostgreSQL request
|
protected Map<String,PipeFunction> pipeFunctions
protected DataSource dataSource
protected Connection connection
protected ClassCreator classCreator
protected String defaultTimeOutLimit
protected Class<? extends SpgeedMapper> defaultMapper
public SqlSession()
public SqlSession(String url, String username, String password)
public SqlSession(DataSource dataSource)
public Class<? extends SpgeedMapper> getDefaultMapper()
public void setDefaultMapper(Class<? extends SpgeedMapper> defaultMapper)
defaultMapper - class wanted as default mapperpublic String getDefaultTimeOutLimit()
public void setDefaultTimeOutLimit(String defaultTimeOutLimit)
defaultTimeOutLimit - time wanted as default limitpublic DataSource getDataSource()
public void addFunction(String name, PipeFunction function)
public void addFunction(Map<String,PipeFunction> functions)
public Map<String,PipeFunction> getPipeFunctions()
public Connection getConnection() throws SQLException
SQLExceptionpublic void commit()
throws SQLException
SQLExceptionpublic void rollback()
throws SQLException
SQLExceptionpublic void close()
throws SQLException
close in interface AutoCloseableSQLExceptionpublic <E> E getDao(Class<E> klass, Object... args)
klass - class of Dao wantedargs - args use to create dao, dao must has constructor with that argspublic <E> E executeQuery(String sql, Map<String,Object> parameters, Class<E> returnClass, String... roles) throws Exception
Exceptionpublic int executeUpdate(String sql, Map<String,Object> parameters, String... roles) throws Exception
ExceptionCopyright © 2017–2020 CodeLutin. All rights reserved.