package com.yan.dao;
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.yan.hib.Users;
/**
* A data access object (DAO) providing persistence and search support for Users
* 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.yan.hib.Users
* @author MyEclipse Persistence Tools
*/
public class UsersDAO extends HibernateDaoSupport implements IUserDao {
private static final Log log = LogFactory.getLog(UsersDAO.class);
// property constants
public static final String USERNAME = "username";
public static final String PASSWORD = "password";
protected void initDao() {
// do nothing
}
public void save(Users transientInstance) {
log.debug("saving Users instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Users persistentInstance) {
log.debug("deleting Users instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Users findById(java.lang.Integer id) {
log.debug("getting Users instance with id: " + id);
try {
Users instance = (Users) getHibernateTemplate().get(
"com.yan.hib.Users", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List<Users> findByExample(Users instance) {
log.debug("finding Users instance by example");
try {
System.out.println(instance.getUsername()+":"+instance.getPassword());
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 Users instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Users 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 Users instances");
try {
String queryString = "from Users";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Users merge(Users detachedInstance) {
log.debug("merging Users instance");
try {
Users result = (Users) getHibernateTemplate().merge(
detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Users instance) {
log.debug("attaching dirty Users instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Users instance) {
log.debug("attaching clean Users instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static UsersDAO getFromApplicationContext(ApplicationContext ctx) {
return (UsersDAO) ctx.getBean("UsersDAO");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
ssh(strute1/2+hibernate3.2+spring2.5)配合的用户登陆注册 (133个子文件)
UsersDAO.class 6KB
UsersDAO.class 5KB
UsersDAO.class 5KB
UsersDAO.class 5KB
LoginAction.class 3KB
LoginAction.class 2KB
LoginAction.class 2KB
LoginAction.class 2KB
LoginForm.class 2KB
LoginForm.class 2KB
LoginForm.class 2KB
Users.class 1KB
Users.class 1KB
Users.class 1KB
Users.class 1KB
UserServImpl.class 1KB
UserServImpl.class 1KB
UserServImpl.class 1KB
UserServImpl.class 1KB
UsersBean.class 1013B
IUserDao.class 254B
IUserDao.class 254B
IUserDao.class 254B
IUserDao.class 254B
A.class 253B
IUserServ.class 165B
IUserServ.class 165B
IUserServ.class 165B
IUserServ.class 160B
struts-2.1.dtd 4KB
struts-2.1.dtd 4KB
UsersDAO.java 4KB
UsersDAO.java 4KB
UsersDAO.java 4KB
UsersDAO.java 4KB
LoginForm.java 2KB
LoginForm.java 2KB
LoginForm.java 2KB
LoginAction.java 2KB
LoginAction.java 1KB
LoginAction.java 1KB
LoginAction.java 975B
Users.java 884B
Users.java 884B
Users.java 884B
Users.java 884B
UsersBean.java 558B
UserServImpl.java 545B
UserServImpl.java 545B
UserServImpl.java 545B
UserServImpl.java 540B
IUserDao.java 159B
IUserDao.java 159B
IUserDao.java 159B
IUserDao.java 159B
A.java 151B
IUserServ.java 139B
IUserServ.java 139B
IUserServ.java 139B
IUserServ.java 136B
show.jsp 841B
show.jsp 841B
show.jsp 841B
index.jsp 837B
index.jsp 837B
index.jsp 837B
index.jsp 837B
login.jsp 622B
login.jsp 622B
login.jsp 620B
login.jsp 432B
.struts-config.mex 838B
.struts-config.mex 837B
.struts-config.mex 797B
MANIFEST.MF 39B
MANIFEST.MF 39B
MANIFEST.MF 39B
MANIFEST.MF 39B
log4j.properties 202B
log4j.properties 202B
ApplicationResources.properties 78B
ApplicationResources.properties 78B
ApplicationResources.properties 78B
ApplicationResources.properties 78B
ApplicationResources.properties 59B
ApplicationResources.properties 59B
struts-html.tld 72KB
struts-html.tld 72KB
struts-html.tld 72KB
struts-nested.tld 70KB
struts-nested.tld 70KB
struts-nested.tld 70KB
spring-form.tld 51KB
spring-form.tld 51KB
spring-form.tld 51KB
spring-form.tld 51KB
struts-logic.tld 14KB
struts-logic.tld 14KB
struts-logic.tld 14KB
spring.tld 13KB
共 133 条
- 1
- 2
资源评论
- zqf08012013-05-10谢谢,对我帮着蛮大的,最近正在研究这个
- Jassica-M2015-06-08谢谢~~终于有一个能看懂的了
- gao_shengxian2015-01-07还不错,知识和学的不同有很多不懂
yinzisheng
- 粉丝: 18
- 资源: 22
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功