当前位置: 首页>>代码示例>>Java>>正文


Java SqlSession.commit方法代码示例

本文整理汇总了Java中org.apache.ibatis.session.SqlSession.commit方法的典型用法代码示例。如果您正苦于以下问题:Java SqlSession.commit方法的具体用法?Java SqlSession.commit怎么用?Java SqlSession.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ibatis.session.SqlSession的用法示例。


在下文中一共展示了SqlSession.commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteToken

import org.apache.ibatis.session.SqlSession; //导入方法依赖的package包/类
public static boolean deleteToken(String tokenId) {
	if (StringUtil.stringIsNull(tokenId)) {
		return false;
	}
	Token token = getTokenById(tokenId);
	if (token == null) {
		return false;
	}
	SqlSession sqlSession = null;
	try {
		sqlSession = MybatisManager.getSqlSession();
		TokenMapper tokenMapper = sqlSession.getMapper(TokenMapper.class);
		int result = tokenMapper.deleteByPrimaryKey(tokenId);
		if (result == 0) {
			MybatisManager.log.warn("删除token失败");
			return false;
		}
		sqlSession.commit();
		return true;
	} catch (Exception e) {
		if (sqlSession != null) {
			sqlSession.rollback();
		}
		MybatisManager.log.error("删除token异常", e);
		return false;
	} finally {
		if (sqlSession != null) {
			sqlSession.close();
		}
	}
}
 
开发者ID:dianbaer,项目名称:startpoint,代码行数:32,代码来源:TokenAction.java

示例2: createNotify

import org.apache.ibatis.session.SqlSession; //导入方法依赖的package包/类
public static Notify createNotify(String appId, String orderRecordId, int notifyType) {
	if (StringUtil.stringIsNull(orderRecordId) || StringUtil.stringIsNull(appId)) {
		return null;
	}
	if (notifyType != NotifyConfig.TYPE_RETURN && notifyType != NotifyConfig.TYPE_NOTIFY) {
		return null;
	}
	Date date = new Date();
	Notify notify = new Notify();
	notify.setNotifyId(IdUtil.getUuid());
	notify.setOrderRecordId(orderRecordId);
	notify.setAppId(appId);
	notify.setNotifyCreateTime(date);
	Date expireTime = new Date(date.getTime() + CommonConfig.NOTIFY_EXPIRE_TIME);
	notify.setNotifyExpireTime(expireTime);
	notify.setNotifyType((byte) notifyType);
	SqlSession sqlSession = null;
	try {
		sqlSession = MybatisManager.getSqlSession();
		NotifyMapper notifyMapper = sqlSession.getMapper(NotifyMapper.class);
		int result = notifyMapper.insert(notify);
		if (result != 1) {
			MybatisManager.log.warn("创建notify失败");
			return null;
		}
		sqlSession.commit();
	} catch (Exception e) {
		if (sqlSession != null) {
			sqlSession.rollback();
		}
		MybatisManager.log.error("创建notify失败", e);
		return null;
	} finally {
		if (sqlSession != null) {
			sqlSession.close();
		}
	}
	return notify;
}
 
开发者ID:dianbaer,项目名称:epay,代码行数:40,代码来源:NotifyAction.java

示例3: updateNotify

import org.apache.ibatis.session.SqlSession; //导入方法依赖的package包/类
public static Notify updateNotify(String notifyId, String notifyResult) {
	if (StringUtil.stringIsNull(notifyId)) {
		return null;
	}
	Notify notify = getNotify(notifyId);
	if (notify == null) {
		return null;
	}
	Notify notifyNew = new Notify();
	notifyNew.setNotifyId(notifyId);
	notifyNew.setNotifyResult(notifyResult);

	SqlSession sqlSession = null;
	try {
		sqlSession = MybatisManager.getSqlSession();
		NotifyMapper notifyMapper = sqlSession.getMapper(NotifyMapper.class);
		int result = notifyMapper.updateByPrimaryKeySelective(notifyNew);
		if (result != 1) {
			MybatisManager.log.warn("修改notify失败");
			return null;
		}
		sqlSession.commit();
	} catch (Exception e) {
		if (sqlSession != null) {
			sqlSession.rollback();
		}
		MybatisManager.log.error("修改notify异常", e);
		return null;
	} finally {
		if (sqlSession != null) {
			sqlSession.close();
		}
	}
	return getNotify(notifyNew.getNotifyId());
}
 
开发者ID:dianbaer,项目名称:epay,代码行数:36,代码来源:NotifyAction.java

示例4: createPayNotifyLog

import org.apache.ibatis.session.SqlSession; //导入方法依赖的package包/类
public static PayNotifyLog createPayNotifyLog(String orderRecordId, String payNotifyLogBody) {
	if (StringUtil.stringIsNull(payNotifyLogBody) || StringUtil.stringIsNull(orderRecordId)) {
		return null;
	}
	Date date = new Date();
	PayNotifyLog payNotifyLog = new PayNotifyLog();
	payNotifyLog.setPayNotiftyLogId(IdUtil.getUuid());
	payNotifyLog.setOrderRecordId(orderRecordId);
	payNotifyLog.setPayNotifyCreateTime(date);
	payNotifyLog.setPayNotifyLogBody(payNotifyLogBody);
	SqlSession sqlSession = null;
	try {
		sqlSession = MybatisManager.getSqlSession();
		PayNotifyLogMapper payNotifyLogMapper = sqlSession.getMapper(PayNotifyLogMapper.class);
		int result = payNotifyLogMapper.insert(payNotifyLog);
		if (result != 1) {
			MybatisManager.log.warn("创建PayNotifyLog失败");
			return null;
		}
		sqlSession.commit();
	} catch (Exception e) {
		if (sqlSession != null) {
			sqlSession.rollback();
		}
		MybatisManager.log.error("创建PayNotifyLog失败", e);
		return null;
	} finally {
		if (sqlSession != null) {
			sqlSession.close();
		}
	}
	return payNotifyLog;
}
 
开发者ID:dianbaer,项目名称:epay,代码行数:34,代码来源:PayNotifyLogAction.java

示例5: unitTest

import org.apache.ibatis.session.SqlSession; //导入方法依赖的package包/类
@Test
public void unitTest() throws Exception {
	Reader r = Resources.getResourceAsReader("config/SqlMapConfig.xml");
	SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(r);
	SqlSession session = factory.openSession();


	List list = session.selectList("adminMapper.selectActiveMember");
	System.out.println(list + "검색성공~!");
	
	List<Course> list1 = session.selectList("adminMapper.selectAllCourseList");
	for (Course v : list1) {
		System.out.println(v + "검색성공~!");
	}
	
	String userId="2222";
	String role="ROLE_ADMIN";
	Map<String, Object> map = new HashMap<String, Object>();
	map.put("userId", userId);
	map.put("role", role);
	int changeAuthority = session.update("adminMapper.changeAuthority", map);
	session.commit();
	System.out.println(changeAuthority + "업데이트 성공,, 랭킹 순번 먹임 !");

	
	
	/*String isAccept = "1";
	String courseNo = "1";
	Map<String, Object> map1 = new HashMap<String, Object>();
	map1.put("isAccept", isAccept);
	map1.put("courseNo", courseNo);
	int changeAcceptStatus = session.update("adminMapper.changeAcceptStatus", map1);
	System.out.println(changeAcceptStatus + "업데이트 성공 !");
	session.commit();*/

}
 
开发者ID:INSUPARK83,项目名称:way_learning,代码行数:37,代码来源:Admin_MyBatisUnitAppTest.java

示例6: updateChat

import org.apache.ibatis.session.SqlSession; //导入方法依赖的package包/类
public static boolean updateChat(List<String> chatIdList) {
	if (chatIdList == null || chatIdList.size() == 0) {
		return false;
	}
	SqlSession sqlSession = null;
	Chat chat = new Chat();
	chat.setChatType((byte) ChatConfig.CHAT_TYPE_RECEIVE);
	try {
		sqlSession = MybatisManager.getSqlSession();
		ChatMapper chatMapper = sqlSession.getMapper(ChatMapper.class);
		ChatCriteria chatCriteria = new ChatCriteria();
		ChatCriteria.Criteria criteria = chatCriteria.createCriteria();
		criteria.andChatIdIn(chatIdList);
		int result = chatMapper.updateByExampleSelective(chat, chatCriteria);
		if (result == 0) {
			MybatisManager.log.warn("修改用户聊天内容失败");
			return false;
		}
		if (result != chatIdList.size()) {
			MybatisManager.log.warn("修改用户聊天内容失败,提交" + chatIdList.size() + "条,修改" + result + "条");
		}
		sqlSession.commit();
	} catch (Exception e) {
		if (sqlSession != null) {
			sqlSession.rollback();
		}
		MybatisManager.log.error("修改用户聊天内容异常", e);
		return false;
	} finally {
		if (sqlSession != null) {
			sqlSession.close();
		}
	}
	return true;
}
 
开发者ID:dianbaer,项目名称:anychat,代码行数:36,代码来源:ChatAction.java

示例7: addVendorMac

import org.apache.ibatis.session.SqlSession; //导入方法依赖的package包/类
@Override
public void addVendorMac(VendorMacBean vendorMacBean) {
    SqlSession sqlSession = MybatisSqlSession.getSqlSession();

    try {
        VendorMacDao vendorMacDao = sqlSession.getMapper(VendorMacDao.class);
        vendorMacDao.addVendorMac(vendorMacBean);
        sqlSession.commit();
    } catch (Exception e) {
        e.printStackTrace();
        logger.error(e.getStackTrace());
    } finally {
        sqlSession.close();
    }
}
 
开发者ID:wanghan0501,项目名称:WiFiProbeAnalysis,代码行数:16,代码来源:VendorMacDaoImpl.java

示例8: updateToken

import org.apache.ibatis.session.SqlSession; //导入方法依赖的package包/类
public static Token updateToken(String tokenId) {
	if (StringUtil.stringIsNull(tokenId)) {
		return null;
	}
	Token token = getTokenById(tokenId);
	if (token == null) {
		return null;
	}
	token = new Token();
	Date date = new Date();
	token.setTokenId(tokenId);
	token.setTokenUpdateTime(date);
	Date expireTime = new Date(date.getTime() + CommonConfigUCenter.TOKEN_EXPIRE_TIME);
	token.setTokenExpireTime(expireTime);

	SqlSession sqlSession = null;
	try {
		sqlSession = MybatisManager.getSqlSession();
		TokenMapper tokenMapper = sqlSession.getMapper(TokenMapper.class);
		int result = tokenMapper.updateByPrimaryKeySelective(token);
		if (result == 0) {
			MybatisManager.log.warn("更新token失败");
			return null;
		}
		sqlSession.commit();
		return token;
	} catch (Exception e) {
		if (sqlSession != null) {
			sqlSession.rollback();
		}
		MybatisManager.log.error("更新token异常", e);
		return null;
	} finally {
		if (sqlSession != null) {
			sqlSession.close();
		}
	}
}
 
开发者ID:dianbaer,项目名称:startpoint,代码行数:39,代码来源:TokenAction.java

示例9: updateUserList

import org.apache.ibatis.session.SqlSession; //导入方法依赖的package包/类
public static boolean updateUserList(List<String> userList, String userGroupId) {
	SqlSession sqlSession = null;
	User user = new User();
	user.setUserGroupId(userGroupId);
	try {
		sqlSession = MybatisManager.getSqlSession();
		UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
		UserCriteria userCriteria = new UserCriteria();
		UserCriteria.Criteria criteria = userCriteria.createCriteria();
		criteria.andUserIdIn(userList);
		int result = userMapper.updateByExampleSelective(user, userCriteria);
		if (result == 0) {
			MybatisManager.log.warn("修改用户失败");
			return false;
		}
		sqlSession.commit();
	} catch (Exception e) {
		if (sqlSession != null) {
			sqlSession.rollback();
		}
		MybatisManager.log.error("修改用户异常", e);
		return false;
	} finally {
		if (sqlSession != null) {
			sqlSession.close();
		}
	}
	return true;
}
 
开发者ID:dianbaer,项目名称:startpoint,代码行数:30,代码来源:UserAction.java

示例10: main

import org.apache.ibatis.session.SqlSession; //导入方法依赖的package包/类
/**
 * 测试 Mybatis XML 修改自动刷新
 */
public static void main(String[] args) throws IOException, InterruptedException {
    InputStream in = UserMapperTest.class.getClassLoader().getResourceAsStream("mysql-config.xml");
    MybatisSessionFactoryBuilder mf = new MybatisSessionFactoryBuilder();
    mf.setGlobalConfig(new GlobalConfiguration(new MySqlInjector()));
    Resource[] resource = new ClassPathResource[]{new ClassPathResource("mysql/UserMapper.xml")};
    SqlSessionFactory sessionFactory = mf.build(in);
    new MybatisMapperRefresh(resource, sessionFactory, 0, 5);
    boolean isReturn = false;
    SqlSession session = null;
    while (!isReturn) {
        try {
            session = sessionFactory.openSession();
            UserMapper userMapper = session.getMapper(UserMapper.class);
            userMapper.selectListRow(new Pagination(1, 10));
            resource[0].getFile().setLastModified(SystemClock.now());
            session.commit();
            session.close();
            Thread.sleep(5000);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (session != null) {
                session.close();
            }
            Thread.sleep(5000);
        }
    }
    System.exit(0);
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:33,代码来源:MybatisMapperRefreshTest.java

示例11: createChatGroup

import org.apache.ibatis.session.SqlSession; //导入方法依赖的package包/类
public static ChatGroup createChatGroup(String chatGroupName, String userGroupId) {
	if (StringUtil.stringIsNull(chatGroupName)) {
		return null;
	}
	ChatGroup chatGroup = new ChatGroup();
	chatGroup.setChatGroupId(IdUtil.getUuid());
	chatGroup.setChatGroupName(chatGroupName);
	chatGroup.setChatGroupCreateTime(new Date());
	if (!StringUtil.stringIsNull(userGroupId)) {
		chatGroup.setUserGroupId(userGroupId);
	}
	SqlSession sqlSession = null;
	try {
		sqlSession = MybatisManager.getSqlSession();
		ChatGroupMapper chatGroupMapper = sqlSession.getMapper(ChatGroupMapper.class);
		int result = chatGroupMapper.insert(chatGroup);
		if (result == 0) {
			MybatisManager.log.warn("创建聊天组失败");
			return null;
		}
		sqlSession.commit();
		return chatGroup;
	} catch (Exception e) {
		if (sqlSession != null) {
			sqlSession.rollback();
		}
		MybatisManager.log.error("创建聊天组异常", e);
		return null;
	} finally {
		if (sqlSession != null) {
			sqlSession.close();
		}
	}
}
 
开发者ID:dianbaer,项目名称:anychat,代码行数:35,代码来源:ChatGroupAction.java

示例12: update

import org.apache.ibatis.session.SqlSession; //导入方法依赖的package包/类
/**
 * 执行数据变更,成功提交失败回滚
 * @param executor 执行器
 * @param <T> 返回指定类型的结果
 * @return 返回值
 */
public <T> T update(MybatisExecutor<T> executor) {
    SqlSession sqlSession = getSession();
    try {
        T t = executor.execute(sqlSession);
        sqlSession.commit();
        return t;
    } catch (Exception e) {
        sqlSession.rollback();
        throw new MybatisExecutorException(e);
    } finally {
        sqlSession.close();
    }
}
 
开发者ID:BriData,项目名称:DBus,代码行数:20,代码来源:MybatisTemplate.java

示例13: createChatGroupUser

import org.apache.ibatis.session.SqlSession; //导入方法依赖的package包/类
public static ChatGroupUser createChatGroupUser(String userId, String chatGroupId, String chatGroupUserRealName, int chatGroupUserRole) {
	if (StringUtil.stringIsNull(userId) || StringUtil.stringIsNull(chatGroupId)) {
		return null;
	}
	ChatGroupUser chatGroupUser = new ChatGroupUser();
	chatGroupUser.setUserId(userId);
	chatGroupUser.setChatGroupId(chatGroupId);
	if (!StringUtil.stringIsNull(chatGroupUserRealName)) {
		chatGroupUser.setChatGroupUserRealName(chatGroupUserRealName);
	}
	if (chatGroupUserRole == ChatGroupUserConfig.CHAT_GROUP_USER_ROLE_ADMIN) {
		chatGroupUser.setChatGroupUserRole((byte) chatGroupUserRole);
	} else {
		chatGroupUser.setChatGroupUserRole((byte) ChatGroupUserConfig.CHAT_GROUP_USER_ROLE_MEMBER);
	}
	chatGroupUser.setChatGroupUserUpdateTime(new Date());
	SqlSession sqlSession = null;
	try {
		sqlSession = MybatisManager.getSqlSession();
		ChatGroupUserMapper chatGroupUserMapper = sqlSession.getMapper(ChatGroupUserMapper.class);
		int result = chatGroupUserMapper.insert(chatGroupUser);
		if (result == 0) {
			MybatisManager.log.warn("创建聊天组用户失败");
			return null;
		}
		sqlSession.commit();
		return chatGroupUser;
	} catch (Exception e) {
		if (sqlSession != null) {
			sqlSession.rollback();
		}
		MybatisManager.log.error("创建聊天组用户异常", e);
		return null;
	} finally {
		if (sqlSession != null) {
			sqlSession.close();
		}
	}
}
 
开发者ID:dianbaer,项目名称:anychat,代码行数:40,代码来源:ChatGroupUserAction.java

示例14: createApp

import org.apache.ibatis.session.SqlSession; //导入方法依赖的package包/类
public static App createApp(String appName, String appReturnUrl, String appNotifyUrl) {
	if (StringUtil.stringIsNull(appName)) {
		return null;
	}
	Date date = new Date();
	App app = new App();
	app.setAppId(IdUtil.getUuid());
	app.setAppName(appName);
	app.setAppKey(IdUtil.getUuid());
	app.setAppCreateTime(date);
	app.setAppUpdateTime(date);
	app.setAppState((byte) AppConfig.STATE_USABLE);
	if (!StringUtil.stringIsNull(appReturnUrl)) {
		app.setAppReturnUrl(appReturnUrl);
	}
	if (!StringUtil.stringIsNull(appNotifyUrl)) {
		app.setAppNotifyUrl(appNotifyUrl);
	}
	SqlSession sqlSession = null;
	try {
		sqlSession = MybatisManager.getSqlSession();
		AppMapper appMapper = sqlSession.getMapper(AppMapper.class);
		int result = appMapper.insert(app);
		if (result != 1) {
			MybatisManager.log.warn("创建app失败");
			return null;
		}
		sqlSession.commit();
	} catch (Exception e) {
		if (sqlSession != null) {
			sqlSession.rollback();
		}
		MybatisManager.log.error("创建app失败", e);
		return null;
	} finally {
		if (sqlSession != null) {
			sqlSession.close();
		}
	}
	return app;
}
 
开发者ID:dianbaer,项目名称:epay,代码行数:42,代码来源:AppAction.java

示例15: main

import org.apache.ibatis.session.SqlSession; //导入方法依赖的package包/类
/**
 * @param args
 * @throws IOException 
 * @throws SQLException 
 */
public static void main(String[] args) throws IOException, SQLException {
	String resource = "mybatis-config.xml";
	Reader reader = Resources.getResourceAsReader(resource);
	SqlSessionFactory sqlsf = new SqlSessionFactoryBuilder().build(reader);

	SqlSession session = sqlsf.openSession();
	CIMapper ciMapper = session.getMapper(CIMapper.class);
	ClazzMapper clMapper = session.getMapper(ClazzMapper.class);
	NSMapper nsMapper = session.getMapper(NSMapper.class);
	RelationMapper rlMapper = session.getMapper(RelationMapper.class);
	DJMapper djMapper = session.getMapper(DJMapper.class);
	CmsRfcProcessor rfcProcessor = new CmsRfcProcessor();
	CmsCmProcessor cmProcessor = new CmsCmProcessor();
	
	//cmMan.setCiMapper(ciMapper);
	//cmMan.setCmValidator(cmValidator);
	//cmMan.setNsManager(nsProc);
	
	cmProcessor.setCiMapper(ciMapper);
	cmProcessor.setCmValidator(cmValidator);
	cmProcessor.setCmsNsProcessor(nsProc);

	cmValidator.setCmsMdProcessor(mdProc);
	cmValidator.setCmsNsProcessor(nsProc);
	
	djValidator.setCmsMdProcessor(mdProc);
	djValidator.setCmsNsProcessor(nsProc);
	
	nsProc.setNsMapper(nsMapper);
	
	CmsMdProcessor mdProcessor = new CmsMdProcessor();
	mdProcessor.setClazzMapper(clMapper);
	mdProcessor.setRelationMapper(rlMapper);
	

	rfcProcessor.setDjMapper(djMapper);
	rfcProcessor.setCmsNsProcessor(nsProc);
	rfcProcessor.setDjValidator(djValidator);
	rfcProcessor.setCiMapper(ciMapper);
	
	djMan.setRfcProcessor(rfcProcessor);
	
	
	CmsCmRfcMrgProcessor cmrfcProcessor = new CmsCmRfcMrgProcessor();
	cmrfcProcessor.setCmProcessor(cmProcessor);
	cmrfcProcessor.setRfcProcessor(rfcProcessor);
	cmrfcProcessor.setDjValidator(djValidator);
	
	cmdjMan.setCmRfcMrgProcessor(cmrfcProcessor);
	
	try {
		//testCreateRelease();
		//testUpdateRelease();
		//testCreateRrfcCi();
		//testUpdateRrfcCi();
		//testRmRrfcCi();
		//testGetRfcCi();
		//testCreateRrfcRelation();
		//testUpdateRrfcRelation();
		testGetRfcCI(); 
		session.commit();
	} finally {
		session.close();
	}
}
 
开发者ID:oneops,项目名称:oneops,代码行数:71,代码来源:DJTests.java


注:本文中的org.apache.ibatis.session.SqlSession.commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。