📄 sqlmapimagedao.java
字号:
/*
* Created on 2004-10-4
* Author: Xuefeng, Copyright (C) 2004, Xuefeng.
*/
package org.crystalblog.dao.ibatis;
import java.util.*;
import java.sql.SQLException;
import org.crystalblog.dao.ImageDao;
import org.crystalblog.domain.Image;
import org.crystalblog.exception.*;
import com.ibatis.sqlmap.client.SqlMapClient;
/**
* Test SqlMapImage.
*
* @author Xuefeng
*/
public class SqlMapImageDao implements ImageDao {
private SqlMapClient sqlMap = SqlConfig.getSqlMapInstance();
public Image getImage(int imageId) throws QueryException {
try {
return (Image)sqlMap.queryForObject("getImage", new Integer(imageId));
}
catch(SQLException sqle) {
throw new QueryException(sqle);
}
}
public List getImages(int categoryId, int num, int page) throws QueryException {
try {
return sqlMap.queryForList("getImages", new Integer(categoryId),
num * (page-1), num);
}
catch(SQLException sqle) {
throw new QueryException(sqle);
}
}
public List getImages(int categoryId) throws QueryException {
try {
return sqlMap.queryForList("getImages", new Integer(categoryId));
}
catch(SQLException sqle) {
throw new QueryException(sqle);
}
}
public int getImagesCount(int categoryId) throws QueryException {
try {
return ((Integer)sqlMap.queryForObject("getImagesCount", new Integer(categoryId))).intValue();
}
catch(SQLException sqle) {
throw new QueryException(sqle);
}
}
public void createImage(Image image) throws CreateException {
try {
sqlMap.insert("createImage", image);
}
catch(SQLException sqle) {
throw new CreateException(sqle);
}
}
public void deleteImage(int imageId) throws DeleteException {
try {
sqlMap.delete("deleteImage", new Integer(imageId));
}
catch(SQLException sqle) {
throw new DeleteException(sqle);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -