use of org.apache.ibatis.session.SqlSessionException in project JessMA by ldcsaa.
the class MyBatisSessionMgr method setSessionTransIsoLevel.
/** 参考:{@link SessionMgr#setSessionTransIsoLevel(TransIsoLevel)} */
@Override
public void setSessionTransIsoLevel(TransIsoLevel level) {
try {
SqlSession session = getSession();
Connection conn = session.getConnection();
conn.setTransactionIsolation(level.toInt());
} catch (SQLException e) {
throw new SqlSessionException(e);
}
}
use of org.apache.ibatis.session.SqlSessionException in project JessMA by ldcsaa.
the class MyBatisSessionMgr method loadDefalutTransIsoLevel.
/** 参考:{@link AbstractSessionMgr#loadDefalutTransIsoLevel()} */
@Override
protected void loadDefalutTransIsoLevel() {
try {
SqlSession session = getSession();
Connection conn = session.getConnection();
int level = conn.getTransactionIsolation();
defaultTransIsoLevel = TransIsoLevel.fromInt(level);
} catch (SQLException e) {
throw new SqlSessionException(e);
} finally {
closeSession();
}
}
use of org.apache.ibatis.session.SqlSessionException in project JessMA by ldcsaa.
the class MyBatisSessionMgr method buildSessionFactory.
/** 创建 {@link SqlSessionFactory} */
private void buildSessionFactory() {
synchronized (this) {
if (sessionFactory == null) {
try {
Reader reader = Resources.getResourceAsReader(configFile);
sessionFactory = new SqlSessionFactoryBuilder().build(reader, environment);
if (GeneralHelper.isStrNotEmpty(pattern)) {
Set<String> packages = PackageHelper.getPackages(pattern);
for (String pkg : packages) {
Set<Class<?>> entities = PackageHelper.getClasses(pkg, false, new ClassFilter() {
@Override
public boolean accept(Class<?> clazz) {
if (!BeanHelper.isPublicInterface(clazz))
return false;
return true;
}
});
Configuration cfg = sessionFactory.getConfiguration();
for (Class<?> clazz : entities) {
if (!cfg.hasMapper(clazz))
cfg.addMapper(clazz);
}
}
}
} catch (IOException e) {
throw new SqlSessionException(e);
}
}
}
}
Aggregations