mybatisはsqlSessionFactoryを使用して一括操作を実現
6377 ワード
sqlSessionFactoryは、一括コミットされたjavaを実装しますが、影響を受ける数を返すことはできません.
転載先:https://www.cnblogs.com/lgjava/p/11263035.html
1 public int updateBatch(List
@Component
public class SpringContextUtil implements ApplicationContextAware{
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
SpringContextUtil.applicationContext = applicationContext;
}
public static ApplicationContext getApplicationContext(){
return applicationContext;
}
public static Object getBean(Class T){
try {
return applicationContext.getBean(T);
}catch (BeansException e){
return null;
}
}
public static Object getBean(String name){
try {
return applicationContext.getBean(name);
}catch (BeansException e){
return null;
}
}
}
転載先:https://www.cnblogs.com/lgjava/p/11263035.html