package com.dao.impl;
import java.util.List;
import org.hibernate.LockMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.dao.UserDao;
import com.vo.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.vo.Users
* @author MyEclipse Persistence Tools
*/
public class UsersDaoImpl extends HibernateDaoSupport implements UserDao {
private static final Logger log = LoggerFactory.getLogger(UsersDaoImpl.class);
protected void initDao() {
// do nothing
}
/* (non-Javadoc)
* @see com.dao.impl.UserDao#save(com.vo.Users)
*/
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;
}
}
/* (non-Javadoc)
* @see com.dao.impl.UserDao#delete(com.vo.Users)
*/
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;
}
}
/* (non-Javadoc)
* @see com.dao.impl.UserDao#findById(java.lang.Integer)
*/
public Users findById(java.lang.Integer id) {
log.debug("getting Users instance with id: " + id);
try {
Users instance = (Users) getHibernateTemplate().get("com.vo.Users",
id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
/* (non-Javadoc)
* @see com.dao.impl.UserDao#findByExample(com.vo.Users)
*/
public List findByExample(Users instance) {
log.debug("finding Users 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;
}
}
/* (non-Javadoc)
* @see com.dao.impl.UserDao#findByProperty(java.lang.String, java.lang.Object)
*/
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;
}
}
/* (non-Javadoc)
* @see com.dao.impl.UserDao#findAll()
*/
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;
}
}
/* (non-Javadoc)
* @see com.dao.impl.UserDao#merge(com.vo.Users)
*/
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 UserDao getFromApplicationContext(ApplicationContext ctx) {
return (UserDao) ctx.getBean("UsersDAO");
}
public boolean login(Users user) {
// TODO Auto-generated method stub
try {
String queryString = "from Users as model where model.username='"+user.getUsername()+"' and model.userpwd ='"+user.getUserpwd()+"'";
return (getHibernateTemplate().find(queryString).size()>0)?true:false;
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
ssh案例(登录动态生成菜单) (133个子文件)
UsersDaoImpl.class 5KB
MenuDaoInpl.class 5KB
Users.class 2KB
UserBizImpl.class 2KB
MenuBizImpl.class 2KB
Menu.class 2KB
MenuAction.class 1KB
showAction.class 1KB
UserDao.class 477B
UserBiz.class 477B
MenuDao.class 434B
MenuBiz.class 434B
GetLoginUser.class 279B
.classpath 7KB
org.eclipse.wst.jsdt.ui.superType.container 49B
struts-2.0.dtd 3KB
struts-2.0.dtd 3KB
hibernate3.jar 2.31MB
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar 1.57MB
xwork-core-2.1.6.jar 1.49MB
aspectjweaver.jar 1.47MB
ojdbc14.jar 1.47MB
jbosscache-core-3.1.0.GA.jar 1.1MB
spring-core-3.2.10.RELEASE.jar 864KB
freemarker-2.3.15.jar 859KB
spring-context-3.2.10.RELEASE.jar 846KB
struts2-core-2.1.8.1.jar 738KB
jboss-cache-1.4.1.GA.jar 690KB
org.springframework.context-3.0.1.RELEASE-A.jar 642KB
spring-web-3.2.10.RELEASE.jar 618KB
com.springsource.com.mchange.v2.c3p0-0.9.1.2.jar 603KB
spring-beans-3.2.10.RELEASE.jar 599KB
c3p0-0.9.1.jar 594KB
javassist-3.9.0.GA.jar 583KB
commons-collections-3.1.jar 546KB
org.springframework.beans-3.0.1.RELEASE-A.jar 535KB
org.springframework.web.struts-3.0.1.RELEASE-A.jar 524KB
log4j-1.2.17.jar 478KB
proxool-0.8.3.jar 465KB
antlr-2.7.6.jar 433KB
spring-jdbc-3.2.10.RELEASE.jar 396KB
org.springframework.web.servlet-3.0.1.RELEASE-A.jar 389KB
com.springsource.org.apache.log4j-1.2.15.jar 387KB
spring-orm-3.2.10.RELEASE.jar 376KB
org.springframework.jdbc-3.0.1.RELEASE-A.jar 369KB
log4j-1.2.14.jar 359KB
org.springframework.web-3.0.1.RELEASE-A.jar 352KB
org.springframework.core-3.0.1.RELEASE-A.jar 347KB
spring-aop-3.2.10.RELEASE.jar 330KB
org.springframework.orm-3.0.1.RELEASE-A.jar 324KB
com.springsource.net.sf.cglib-2.2.0.jar 319KB
org.springframework.aop-3.0.1.RELEASE-A.jar 313KB
dom4j-1.6.1.jar 307KB
com.springsource.org.apache.commons.httpclient-3.1.0.jar 301KB
hibernate-annotations.jar 273KB
cglib-2.2.jar 272KB
com.springsource.org.codehaus.jackson.mapper-1.0.0.jar 264KB
com.springsource.org.apache.commons.lang-2.4.0.jar 258KB
commons-lang.jar 237KB
spring-tx-3.2.10.RELEASE.jar 237KB
ognl-2.7.3.jar 234KB
org.springframework.transaction-3.0.1.RELEASE-A.jar 223KB
ehcache-1.2.3.jar 203KB
spring-expression-3.2.10.RELEASE.jar 192KB
org.springframework.web.portlet-3.0.1.RELEASE-A.jar 169KB
org.springframework.expression-3.0.1.RELEASE-A.jar 152KB
jotm.jar 121KB
commons-dbcp.jar 119KB
hibernate-entitymanager.jar 116KB
aspectjrt.jar 112KB
oscache-2.1.jar 112KB
com.springsource.org.apache.commons.pool-1.5.3.jar 95KB
xapool.jar 90KB
commons-io-1.3.2.jar 86KB
persistence.jar 69KB
hibernate-commons-annotations.jar 65KB
hibernate-validator.jar 61KB
commons-pool.jar 61KB
com.springsource.org.apache.commons.logging-1.1.1.jar 60KB
commons-logging.jar 59KB
commons-fileupload-1.2.1.jar 56KB
org.springframework.oxm-3.0.1.RELEASE-A.jar 56KB
com.springsource.org.apache.commons.fileupload-1.2.0.jar 53KB
org.springframework.asm-3.0.1.RELEASE-A.jar 52KB
spring-aspects-3.2.10.RELEASE.jar 50KB
ejb3-persistence.jar 49KB
spring-struts-3.2.10.RELEASE.jar 35KB
swarmcache-1.0RC2.jar 30KB
org.springframework.aspects-3.0.1.RELEASE-A.jar 29KB
slf4j-api-1.5.8.jar 23KB
struts2-spring-plugin-2.1.8.1.jar 16KB
jta-1.1.jar 13KB
slf4j-log4j12-1.5.8.jar 9KB
org.springframework.instrument.tomcat-3.0.1.RELEASE-A.jar 5KB
com.springsource.org.aopalliance-1.0.0.jar 5KB
aopalliance.jar 4KB
org.springframework.instrument-3.0.1.RELEASE-A.jar 2KB
UsersDaoImpl.java 5KB
MenuDaoInpl.java 4KB
UserBizImpl.java 2KB
共 133 条
- 1
- 2
资源评论
- uuuuuuf2016-01-20谢谢分享,没什么帮助!
- hitro_lfc2017-04-17谢谢分享,真没什么帮助!
fengqilove520
- 粉丝: 25
- 资源: 91
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功