IbatisTemplate.java
上传用户:liangcc
上传日期:2019-05-24
资源大小:4412k
文件大小:2k
- package com.softeem.ibatis3;
- import java.sql.SQLException;
- import java.util.List;
- import java.util.Map;
- import com.ibatis.sqlmap.client.SqlMapSession;
- public class IbatisTemplate {
-
- protected SqlMapSession session = null;
-
- public IbatisTemplate() {
- session = IbatisSqlMapSessionFactory.getSqlMapSession();
- }
-
- //插入
- public Object insert(String id, Object parameterObject) throws SQLException {
- return session.insert(id, parameterObject);
- }
-
- //查询多行
- public List queryForList(String id, Object parameterObject) throws SQLException {
- return session.queryForList(id, parameterObject);
- }
-
- //查询单行
- public Object queryForObject(String id, Object parameterObject) throws SQLException {
- return session.queryForObject(id, parameterObject);
- }
-
- //更新
- public int update(String id, Object parameterObject) throws SQLException {
- return session.update(id, parameterObject);
- }
-
- //删除
- public int delete(String id, Object parameterObject) throws SQLException {
- return session.delete(id, parameterObject);
- }
-
- //开启事务
- public void openTransaction() throws SQLException {
- session.startTransaction();
- }
-
- //提交事务
- public void commintTransaction() throws SQLException {
- session.commitTransaction();
- }
-
- //结束事务,事务没有完成 回滚
- public void endTransaction() throws SQLException {
- session.endTransaction();
- }
- }