link.jfire.sql.util.AutoCloseSession Maven / Gradle / Ivy
package link.jfire.sql.util;
import javax.annotation.Resource;
import link.jfire.baseutil.simplelog.ConsoleLogFactory;
import link.jfire.baseutil.simplelog.Logger;
import link.jfire.baseutil.tx.AutoCloseManager;
import link.jfire.sql.function.SessionFactory;
import link.jfire.sql.function.SqlSession;
@Resource
public class AutoCloseSession implements AutoCloseManager
{
@Resource
private SessionFactory sessionFactory;
private static Logger logger = ConsoleLogFactory.getLogger();
@Override
public void close()
{
logger.trace("关闭当前session{}", sessionFactory.getCurrentSession());
SqlSession session = sessionFactory.getCurrentSession();
if (session != null)
{
session.close();
}
}
}