package com.ssh.dao.impl;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.ssh.dao.IUserDAO;
import com.ssh.user.User;
/**
* A data access object (DAO) providing persistence and search support for User
* entities. Transaction control of the save(), update() and delete() operations
* can directly support Spring container-managed transactions or they can be
* augmented to handle user-managed Spring transactions. Each of these methods
* provides additional information for how to configure it for the desired type
* of transaction control.
*
* @see com.ssh.user.User
* @author MyEclipse Persistence Tools
*/
public class UserDAO extends HibernateDaoSupport implements IUserDAO {
private static final Log log = LogFactory.getLog(UserDAO.class);
// property constants
public static final String USERNAME = "username";
public static final String PASSWORD = "password";
protected void initDao() {
// do nothing
}
public void save(User transientInstance) {
log.debug("saving User instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(User persistentInstance) {
log.debug("deleting User instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public User findById(java.lang.Integer id) {
log.debug("getting User instance with id: " + id);
try {
User instance = (User) getHibernateTemplate().get(
"com.ssh.user.User", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(User instance) {
log.debug("finding User instance by example");
try {
List results = getHibernateTemplate().findByExample(instance);
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
public List findByProperty(String propertyName, Object value) {
log.debug("finding User instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from User as model where model."
+ propertyName + "= ?";
return getHibernateTemplate().find(queryString, value);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List findByUsername(Object username) {
return findByProperty(USERNAME, username);
}
public List findByPassword(Object password) {
return findByProperty(PASSWORD, password);
}
public List findAll() {
log.debug("finding all User instances");
try {
String queryString = "from User";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public User merge(User detachedInstance) {
log.debug("merging User instance");
try {
User result = (User) getHibernateTemplate().merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(User instance) {
log.debug("attaching dirty User instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(User instance) {
log.debug("attaching clean User instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static UserDAO getFromApplicationContext(ApplicationContext ctx) {
return (UserDAO) ctx.getBean("UserDAO");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
用户登录(Struts1.2+Spring2.5+Hibernate3.2)
共42个文件
java:8个
class:8个
tld:7个
4星 · 超过85%的资源 需积分: 9 44 下载量 47 浏览量
2011-09-26
16:28:20
上传
评论
收藏 687KB RAR 举报
温馨提示
1、可以运行(发布后,删除\Tomcat 6.0\webapps\ssh\WebRoot\WEB-INF\lib下的asm-2.2.3.jar) 2、采用Struts1.2 + Spring2.5 + Hibernate3.2 整合开发 3、SSH入门级实例
资源推荐
资源详情
资源评论
收起资源包目录
ssh.rar (42个子文件)
ssh
.mystrutsdata 254B
.springBeans 479B
.myhibernatedata 558B
src
com
ssh
dao
IUserDAO.java 229B
impl
UserDAO.java 4KB
user
User.hbm.xml 788B
User.java 881B
service
IUserService.java 222B
impl
UserService.java 718B
struts
ApplicationResources.properties 78B
form
LoginForm.java 2KB
action
LoginAction.java 1KB
BaseAction.java 476B
.project 2KB
WebRoot
META-INF
MANIFEST.MF 39B
WEB-INF
struts-nested.tld 70KB
validator-rules.xml 13KB
struts-bean.tld 9KB
struts-html.tld 72KB
struts-logic.tld 14KB
struts-tiles.tld 8KB
web.xml 1KB
.struts-config.mex 836B
classes
com
ssh
dao
IUserDAO.class 275B
impl
UserDAO.class 5KB
user
User.hbm.xml 788B
User.class 1KB
service
IUserService.class 299B
impl
UserService.class 1KB
struts
ApplicationResources.properties 78B
form
LoginForm.class 1KB
action
LoginAction.class 2KB
BaseAction.class 1007B
struts-config.xml 790B
lib
mysql-connector-java-5.1.6-bin.jar 687KB
spring.tld 13KB
spring-form.tld 71KB
applicationContext.xml 1KB
login.jsp 553B
index.jsp 834B
.mymetadata 282B
.classpath 1KB
.myeclipse
共 42 条
- 1
资源评论
- qq_314770412017-10-22都没下载。C币就扣掉了?
- woodpecker_mugua2012-03-23采用Struts1.2 + Spring2.5 + Hibernate3.2 整合开发 很不错
- mengqizhangqi2014-01-24很不错 学习了
- justforxugaofeng2013-04-04比较适合入门
- bluessh2012-08-07还行。。。。。。。可惜和我的项目出入太大、基本没有参考意义了。。。。
cristina_2011
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功