保存进度!
This commit is contained in:
@@ -20,8 +20,10 @@ import org.apache.ibatis.session.SqlSessionFactoryBuilder;
|
||||
|
||||
public class MybatisUtils
|
||||
{
|
||||
private static HashMap<String, SqlSession> SessionMap = new HashMap<>(5);
|
||||
private static HashMap<String, SqlSession> SessionMapBatch = new HashMap<>(5);
|
||||
private static HashMap<String, SqlSession> SessionMap = new HashMap<>( 5 );
|
||||
private static HashMap<String, SqlSession> SessionMapBatch = new HashMap<>( 5 );
|
||||
private static HashMap<String, SqlSessionFactory> SessionFactoryMap = new HashMap<>( 5 );
|
||||
private static HashMap<String, SqlSessionFactory> SessionFactoryMapBatch = new HashMap<>( 5 );
|
||||
private static String DEFAULT_CONFIGFILE = "mybatis/mybatis-config.xml";
|
||||
|
||||
/**
|
||||
@@ -33,43 +35,45 @@ public class MybatisUtils
|
||||
public static SqlSession getSqlSession( String configFile ) throws IOException
|
||||
{
|
||||
// 根据配置文件的路径,查找是否已经创建了对应的session
|
||||
SqlSession session = SessionMap.get( configFile );
|
||||
SqlSessionFactory factory = SessionFactoryMap.get( configFile );
|
||||
|
||||
// 找到就直接返回
|
||||
if ( session != null )
|
||||
if ( factory != null )
|
||||
{
|
||||
return session;
|
||||
return factory.openSession();
|
||||
}
|
||||
|
||||
// 没找到就创建一个
|
||||
InputStream configIS = Resources.getResourceAsStream( configFile );
|
||||
SqlSessionFactory factory = new SqlSessionFactoryBuilder().build( configIS );
|
||||
session = factory.openSession();
|
||||
factory = new SqlSessionFactoryBuilder().build( configIS );
|
||||
SqlSession session = factory.openSession();
|
||||
|
||||
// 保存
|
||||
SessionMap.put( configFile, session );
|
||||
SessionFactoryMap.put( configFile, factory );
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
public static SqlSession getSqlSessionBatch( String configFile ) throws IOException
|
||||
{
|
||||
SqlSession sessionBatch = SessionMapBatch.get( configFile );
|
||||
// 根据配置文件的路径,查找是否已经创建了对应的session
|
||||
SqlSessionFactory factory = SessionFactoryMap.get( configFile );
|
||||
|
||||
if ( sessionBatch != null )
|
||||
// 找到就直接返回
|
||||
if ( factory != null )
|
||||
{
|
||||
return sessionBatch;
|
||||
return factory.openSession();
|
||||
}
|
||||
|
||||
// 没有缓存的就创建一个新的
|
||||
// 没找到就创建一个
|
||||
InputStream configIS = Resources.getResourceAsStream( configFile );
|
||||
SqlSessionFactory factory = new SqlSessionFactoryBuilder().build( configIS );
|
||||
sessionBatch = factory.openSession(ExecutorType.BATCH, false );
|
||||
factory = new SqlSessionFactoryBuilder().build( configIS );
|
||||
SqlSession session = factory.openSession( ExecutorType.BATCH, false );
|
||||
|
||||
//保存
|
||||
SessionMapBatch.put( configFile, sessionBatch );
|
||||
// 保存
|
||||
SessionFactoryMap.put( configFile, factory );
|
||||
|
||||
return sessionBatch;
|
||||
return session;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,21 +84,21 @@ public class MybatisUtils
|
||||
public static SqlSession getSqlSession() throws IOException
|
||||
{
|
||||
// 根据配置文件的路径,查找是否已经创建了对应的session
|
||||
SqlSession session = SessionMap.get( DEFAULT_CONFIGFILE );
|
||||
SqlSessionFactory factory = SessionFactoryMap.get( DEFAULT_CONFIGFILE );
|
||||
|
||||
// 找到就直接返回
|
||||
if ( session != null )
|
||||
if ( factory != null )
|
||||
{
|
||||
return session;
|
||||
return factory.openSession();
|
||||
}
|
||||
|
||||
// 没找到就创建一个
|
||||
InputStream configIS = Resources.getResourceAsStream( DEFAULT_CONFIGFILE );
|
||||
SqlSessionFactory factory = new SqlSessionFactoryBuilder().build( configIS );
|
||||
session = factory.openSession();
|
||||
factory = new SqlSessionFactoryBuilder().build( configIS );
|
||||
SqlSession session = factory.openSession();
|
||||
|
||||
// 保存
|
||||
SessionMap.put( DEFAULT_CONFIGFILE, session );
|
||||
SessionFactoryMap.put( DEFAULT_CONFIGFILE, factory );
|
||||
|
||||
return session;
|
||||
}
|
||||
@@ -108,21 +112,23 @@ public class MybatisUtils
|
||||
*/
|
||||
public static SqlSession getSqlSessionBatch() throws IOException
|
||||
{
|
||||
SqlSession sessionBatch = SessionMapBatch.get( DEFAULT_CONFIGFILE );
|
||||
// 根据配置文件的路径,查找是否已经创建了对应的session
|
||||
SqlSessionFactory factory = SessionFactoryMap.get( DEFAULT_CONFIGFILE );
|
||||
|
||||
if ( sessionBatch != null )
|
||||
// 找到就直接返回
|
||||
if ( factory != null )
|
||||
{
|
||||
return sessionBatch;
|
||||
return factory.openSession();
|
||||
}
|
||||
|
||||
// 没有缓存的就创建一个新的
|
||||
// 没找到就创建一个
|
||||
InputStream configIS = Resources.getResourceAsStream( DEFAULT_CONFIGFILE );
|
||||
SqlSessionFactory factory = new SqlSessionFactoryBuilder().build( configIS );
|
||||
sessionBatch = factory.openSession(ExecutorType.BATCH, false );
|
||||
factory = new SqlSessionFactoryBuilder().build( configIS );
|
||||
SqlSession session = factory.openSession( ExecutorType.BATCH, false );
|
||||
|
||||
//保存
|
||||
SessionMapBatch.put( DEFAULT_CONFIGFILE, sessionBatch );
|
||||
// 保存
|
||||
SessionFactoryMap.put( DEFAULT_CONFIGFILE, factory );
|
||||
|
||||
return sessionBatch;
|
||||
return session;
|
||||
}
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ public class CallerArchievement
|
||||
|
||||
params.put( "a_caller_code", callerCode );
|
||||
|
||||
session.clearCache();
|
||||
// session.clearCache();
|
||||
mapper.getCallerArchievement( params );
|
||||
|
||||
// 总业绩
|
||||
|
@@ -38,7 +38,7 @@
|
||||
</insert>
|
||||
|
||||
<select id="cleanTelsalerAttachingRateData" statementType="CALLABLE">
|
||||
call telsale_bi_utils.清理BI电销坐席车非渗透跟踪表()
|
||||
call telsale_bi_utils.清理BI电销坐席车非渗透率跟踪表()
|
||||
</select>
|
||||
<select id="cleanTelsalerRenewalRateData" statementType="CALLABLE">
|
||||
call telsale_bi_utils.清理BI电销坐席续保率跟踪表()
|
||||
|
Reference in New Issue
Block a user