JiveJdon Community Forums
在线358人   首页   主题总表   培训咨询   精华   查搜   注册    登陆
首页 » 论坛 » 开源项目大家谈
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表
???en_US.forumThreadNext.name??? 下一主题
Go 总共有 2 回复 / 1
 发表新帖子   回复该主题贴
xiaowang

悄悄话
发表文章: 2
注册时间: 2006年08月21日 17:45
请教关于ibatis的问题 2006年08月21日 17:53 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
标签列表
小弟最近刚学IBATIS,打算用它用它做一个小应用.我是这么使用SQLmap的,不知道对不对,还希望banq给点意见.
先定义一个类用于封装SqlMap初试化程序.
public class BaseIbatisDao{

private static BaseIbatisDao instance = new BaseIbatisDao();
private static Logger log = Logger.getLogger(BaseIbatisDao.class.getName());
protected static final SqlMapClient sqlMap;

static{
try{
log.debug("Attemping to initialize SqlMap!!!");
String resource = "SqlMapConfig.xml";//在WEB-INF/classes目录下查找该文件
Reader reader = Resources.getResourceAsReader(resource);
sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
log.debug("Initialized SqlMap!!!");
}catch(Exception e){
log.error("Error intializing BaseIbatisDao!!!", e);
e.printStackTrace();
throw new RuntimeException("Error initializing BaseIbatisDao.class Cause: " + e);
}
}
protected BaseIbatisDao(){

}
public static BaseIbatisDao getInstance(){
return instance;
}

}

接着就在具体类中这么使用:
public class UserBaseIbatisDAOImpl extends BaseIbatisDao implements UserDAO{

Log logger = LogFactory.getLog(this.getClass());

public List getAllUser(){
List user = null;
try{
user = sqlMap.queryForList("User.getAll", null);
}catch(SQLException e){
logger.error("Error getting all User!!!", e);
}
return user;
}

public User getUser(String num){
User user = null;
try{
user = (User)sqlMap.queryForObject("User.getByNum", num);
}catch(SQLException e){
logger.error("Error getting User!!!", e);
}
return user;
}

public void insert(User user){
try{
sqlMap.insert("User.insert", user);
}catch(SQLException e){
logger.error("error inserting User!!!", e);
}
}


}
不知道这样使用什么问题.望大家指点指点.谢谢!

xiaowang

悄悄话
发表文章: 2
注册时间: 2006年08月21日 17:45
Re: 请教关于ibatis的问题 2006年08月21日 19:05 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
大家实际项目中是怎么使用IBATIS,能说说吗?小弟刚入门,希望能得到大家的帮助!
banq

悄悄话
发表文章: 9312
注册时间: 2002年08月03日 17:08
Re: 请教关于ibatis的问题 2006年08月23日 09:49 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
不常用,在我的Jpetstore源码中有ibatis使用形式
这个主题有 2 回复 / 1Go
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表    返回页首返回页首
???en_US.forumThreadNext.name??? 下一主题
热点TAG: AOP cache 缓存 DDD EJB 集群 设计模式 Hibernate IOC JiveJdon OO RBAC Seam Spring Struts
正在读取,请等待...
google yahoo 新浪ViVi 365Key网摘 天极网摘 CSDN网摘 添加到百度搜藏 POCO网摘 博采网摘
查询本论坛内 回复超过的热门帖子
     回复该主题贴
标题
 
粗体 斜体 下划线 插入图片 插入代码 插入url链接 插入附件
内容
 

手机阅读 add to google add to yahoo
解惑之道在J道 ,打造中国最具影响力的的企业软件社区
OpenSource JIVEJDON v3.0 Powered by JdonFramework Code © 2002-08 jdon.com
anti spam