The template needs a SqlSessionFactory to create SqlSessions, passed as a constructor argument. It also can be constructed indicating the executor type to be used, if not, the default executor type, defined in the session factory will be used.
This template converts MyBatis PersistenceExceptions into unchecked DataAccessExceptions, using, by default, a {@code MyBatisExceptionTranslator}.
Because SqlSessionTemplate is thread safe, a single instance can be shared by all DAOs; there should also be a small memory savings by doing this. This pattern can be used in Spring configuration files as follows:
{@code@see SqlSessionFactory @see MyBatisExceptionTranslator @version $Id: SqlSessionTemplate.java 3406 2010-12-20 17:58:31Z eduardo.macarron $}
|
|
|
|