sqlmaplinkdao.java

来自「java写的blog」· Java 代码 · 共 80 行

JAVA
80
字号
/*
 * Created on 2004-10-4
 * Author: Xuefeng, Copyright (C) 2004, Xuefeng.
 */
package org.crystalblog.dao.ibatis;

import java.sql.SQLException;
import java.util.List;

import org.crystalblog.dao.LinkDao;
import org.crystalblog.domain.Link;
import org.crystalblog.exception.*;

import com.ibatis.sqlmap.client.SqlMapClient;

/**
 * TODO Description here...
 * 
 * @author Xuefeng
 */
public class SqlMapLinkDao implements LinkDao {

    private SqlMapClient sqlMap = SqlConfig.getSqlMapInstance();

    public List getAllLinks(int accountId) throws QueryException {
        try {
            return sqlMap.queryForList("getAllLinks", new Integer(accountId));
        }
        catch(SQLException sqle) {
            throw new QueryException(sqle);
        }
    }

    public Link getLink(int linkId) throws QueryException {
        try {
            return (Link)sqlMap.queryForObject("getLink", new Integer(linkId));
        }
        catch(SQLException sqle) {
            throw new QueryException(sqle);
        }
    }

    public int getLinksCount(int categoryId) throws QueryException {
        try {
            return ((Integer)sqlMap.queryForObject("getLinksCount", new Integer(categoryId))).intValue();
        }
        catch(SQLException sqle) {
            throw new QueryException(sqle);
        }
    }

    public void createLink(Link link) throws CreateException {
        try {
            sqlMap.insert("createLink", link);
        }
        catch(SQLException sqle) {
            throw new CreateException(sqle);
        }
    }

    public void updateLink(Link link) throws UpdateException {
        try {
            sqlMap.update("updateLink", link);
        }
        catch(SQLException sqle) {
            throw new UpdateException(sqle);
        }
    }

    public void deleteLink(int linkId) throws DeleteException {
        try {
            sqlMap.delete("deleteLink", new Integer(linkId));
        }
        catch(SQLException sqle) {
            throw new DeleteException(sqle);
        }
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?