package ibatis;

import com.ibatis.sqlmap.client.SqlMapClient;
import ibatis.Role;
import ibatis.RoleExample;
import java.sql.SQLException;
import java.util.List;

public class RoleDAOImpl implements RoleDAO {
    /**
     * This field was generated by Apache iBATIS ibator.
     * This field corresponds to the database table role
     *
     * @ibatorgenerated Sun Mar 02 14:59:23 GMT+08:00 2014
     */
    private SqlMapClient sqlMapClient;

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table role
     *
     * @ibatorgenerated Sun Mar 02 14:59:23 GMT+08:00 2014
     */
    public RoleDAOImpl(SqlMapClient sqlMapClient) {
        super();
        this.sqlMapClient = sqlMapClient;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table role
     *
     * @ibatorgenerated Sun Mar 02 14:59:23 GMT+08:00 2014
     */
    public int countByExample(RoleExample example) throws SQLException {
        Integer count = (Integer)  sqlMapClient.queryForObject("role.ibatorgenerated_countByExample", example);
        return count.intValue();
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table role
     *
     * @ibatorgenerated Sun Mar 02 14:59:23 GMT+08:00 2014
     */
    public int deleteByExample(RoleExample example) throws SQLException {
        int rows = sqlMapClient.delete("role.ibatorgenerated_deleteByExample", example);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table role
     *
     * @ibatorgenerated Sun Mar 02 14:59:23 GMT+08:00 2014
     */
    public int deleteByPrimaryKey(Integer roleId) throws SQLException {
        Role key = new Role();
        key.setRoleId(roleId);
        int rows = sqlMapClient.delete("role.ibatorgenerated_deleteByPrimaryKey", key);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table role
     *
     * @ibatorgenerated Sun Mar 02 14:59:23 GMT+08:00 2014
     */
    public Integer insert(Role record) throws SQLException {
        Object newKey = sqlMapClient.insert("role.ibatorgenerated_insert", record);
        return (Integer) newKey;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table role
     *
     * @ibatorgenerated Sun Mar 02 14:59:23 GMT+08:00 2014
     */
    public Integer insertSelective(Role record) throws SQLException {
        Object newKey = sqlMapClient.insert("role.ibatorgenerated_insertSelective", record);
        return (Integer) newKey;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table role
     *
     * @ibatorgenerated Sun Mar 02 14:59:23 GMT+08:00 2014
     */
    public List selectByExample(RoleExample example) throws SQLException {
        List list = sqlMapClient.queryForList("role.ibatorgenerated_selectByExample", example);
        return list;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table role
     *
     * @ibatorgenerated Sun Mar 02 14:59:23 GMT+08:00 2014
     */
    public Role selectByPrimaryKey(Integer roleId) throws SQLException {
        Role key = new Role();
        key.setRoleId(roleId);
        Role record = (Role) sqlMapClient.queryForObject("role.ibatorgenerated_selectByPrimaryKey", key);
        return record;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table role
     *
     * @ibatorgenerated Sun Mar 02 14:59:23 GMT+08:00 2014
     */
    public int updateByExampleSelective(Role record, RoleExample example) throws SQLException {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = sqlMapClient.update("role.ibatorgenerated_updateByExampleSelective", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table role
     *
     * @ibatorgenerated Sun Mar 02 14:59:23 GMT+08:00 2014
     */
    public int updateByExample(Role record, RoleExample example) throws SQLException {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = sqlMapClient.update("role.ibatorgenerated_updateByExample", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table role
     *
     * @ibatorgenerated Sun Mar 02 14:59:23 GMT+08:00 2014
     */
    public int updateByPrimaryKeySelective(Role record) throws SQLException {
        int rows = sqlMapClient.update("role.ibatorgenerated_updateByPrimaryKeySelective", record);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table role
     *
     * @ibatorgenerated Sun Mar 02 14:59:23 GMT+08:00 2014
     */
    public int updateByPrimaryKey(Role record) throws SQLException {
        int rows = sqlMapClient.update("role.ibatorgenerated_updateByPrimaryKey", record);
        return rows;
    }

    /**
     * This class was generated by Apache iBATIS ibator.
     * This class corresponds to the database table role
     *
     * @ibatorgenerated Sun Mar 02 14:59:23 GMT+08:00 2014
     */
    private static class UpdateByExampleParms extends RoleExample {
        private Object record;

        public UpdateByExampleParms(Object record, RoleExample example) {
            super(example);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }
}