Spring2 Hibernate3 Junit 应用示例3
原创
©著作权归作者所有:来自51CTO博客作者xhcat1025的原创作品,请联系作者获取转载授权,否则将追究法律责任
<1>、UserManager
package com.xh.spring.service;
import java.util.List;
import com.xh.hibernate.vo.User;
public interface UserManager {
public List getUsers();
public User getUser(String s);
public void saveUser(User user);
public void removeUser(String s);
public void updateUser(User use);
}
<2>、UserManagerImpl
package com.xh.spring.service.impl;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.xh.hibernate.dao.UserDAO;
import com.xh.hibernate.vo.User;
import com.xh.spring.service.UserManager;
public class UserManagerImpl implements UserManager
{
private static Log log;
private UserDAO dao;
public UserManagerImpl() {
}
public void setUserDAO(UserDAO dao) {
this.dao = dao;
}
public List getUsers() {
return dao.getUsers();
}
public User getUser(String userId) {
User
user = dao.getUser(Integer.valueOf(userId));
if (user == null)
log.warn("userId
'" + userId + "' not found in database.");
return user;
}
public void saveUser(User user) {
dao.saveUser(user);
}
public void removeUser(String userId) {
dao.removeUser(Integer.valueOf(userId));
}
public void updateUser(User user) {
dao.updateUser(user);
}
static {
log = LogFactory
.getLog(com.xh.spring.service.impl.UserManagerImpl.class);
}
}
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
spring3、struts2、hibernate3框架整合
http://blog.csdn.net/neareast/article/details/7457618
整合 struts2 hibernate3 spring3 -
Hibernate3综述
原理:1. 读取并解析配置文件2. 读取并解析映射信息,创建SessionFactory3. 打开Sesssio
职场 Hibernate 休闲 Hibernate 原理 缓存 对象关系 -
Hibernate3的DetachedCriteria支持
Hibernate3的DetachedCriteria支持
Hibernate3 DetachedCriteria