package com.css.shw.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.css.shw.vo.User;
/**
* @author wangyx
*
*/
public class UserDAO extends HibernateDaoSupport {
private static final Log log = LogFactory.getLog(UserDAO.class);
//property constants
public static final String USERNAME = "username";
public static final String PASSWORD = "password";
public static final String SEX = "sex";
public static final String AGE = "age";
public UserDAO(){
super();
System.out.println("UserDAO init....");
}
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.cn.webwork.vo.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 findBySex(Object sex) {
return findByProperty(SEX, sex);
}
public List findByAge(Object age) {
return findByProperty(AGE, age);
}
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");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
shw.rar (99个子文件)
createdb.sql 1KB
shw
.project 2KB
.settings
org.eclipse.jdt.ui.prefs 193B
com.genuitec.eclipse.j2eedt.core.prefs 1KB
.mymetadata 289B
WebRoot
WEB-INF
taglibs-benchmark.tld 1KB
web.xml 1KB
hibernate-mapping-3.0.dtd 41KB
webwork.tld 79KB
teas-web.xml 1KB
applicationContext.xml 2KB
spring.tld 8KB
teas-web.xml.bak 1KB
lib
connector.jar 18KB
oscache-2.1.jar 112KB
spring-web-2.0.8.jar 149KB
poi-2.5.1.jar 783KB
spring-core-2.0.8.jar 178KB
mysql-connector-java-5.0.4-bin.jar 484KB
c3p0-0.9.0.jar 476KB
xwork-spring-1.1.4.jar 10KB
commons-fileupload.jar 22KB
db-ojb-1.0.4.jar 917KB
antlr-2.7.5H3.jar 423KB
commons-collections-2.1.jar 161KB
dom4j-1.6.jar 306KB
cos.jar 55KB
spring-dao-2.0.8.jar 127KB
ognl.jar 162KB
jta.jar 9KB
spring-context-2.0.8.jar 157KB
hibernate3.jar 1.88MB
toplink-api.jar 50KB
commons-logging-api-1.0.2.jar 18KB
c3p0-0.9.0.4.jar 479KB
commons-logging-1.0.4.jar 43KB
commons-javaflow-20060411.jar 94KB
spring-security-acl-2.0.4.jar 68KB
xwork.jar 160KB
rife-continuations.jar 114KB
concurrent-1.3.2.jar 167KB
commons-dbcp-1.2.1.jar 105KB
xml-apis.jar 121KB
spring-security-core-tiger-2.0.4.jar 8KB
spring-beans-2.0.8.jar 381KB
commons-httpclient-3.0.1.jar 273KB
spring-jdbc-2.0.8.jar 222KB
jdbc2_0-stdext.jar 7KB
spring-support-2.0.8.jar 114KB
mysql-connector-java-5.0.3-bin.jar 482KB
commons-io-1.4.jar 106KB
commons-lang-2.1.jar 203KB
ehcache-1.1.jar 46KB
commons-codec-1.3.jar 46KB
swarmcache-1.0rc2.jar 30KB
commons-id.jar 38KB
jdo2.jar 74KB
dom4j-1.6.1.jar 307KB
proxool-0.8.3.jar 465KB
asm.jar 26KB
commons-digester-1.7.jar 137KB
spring-aop-2.0.8.jar 301KB
commons-pool-1.2.jar 41KB
oscore.jar 89KB
spring-hibernate3.jar 105KB
spring-security-core-2.0.4.jar 755KB
xerces-2.6.2.jar 987KB
cglib-2.1.3.jar 276KB
jotm.jar 121KB
commons-beanutils-1.7.jar 184KB
spring-security-taglibs-2.0.4.jar 19KB
jxl.jar 597KB
spring.jar 1.84MB
xalan.jar 974KB
xapool.jar 90KB
commons-discovery-0.2.jar 70KB
freemarker.jar 771KB
webwork-2.1.7.jar 319KB
classes
webwork.properties 31B
xwork.xml 451B
com
css
shw
dao
UserDAO.class 5KB
action
UserAction.class 1KB
vo
User.class 2KB
User.hbm.xml 1006B
service
UserService.class 989B
hibernate-configuration-3.0.dtd 2KB
META-INF
MANIFEST.MF 39B
register_success.jsp 413B
register.jsp 604B
.myeclipse
src
webwork.properties 31B
xwork.xml 451B
com
css
shw
dao
UserDAO.java 4KB
action
UserAction.java 749B
vo
User.java 1KB
User.hbm.xml 1006B
service
UserService.java 477B
.springBeans 295B
.classpath 5KB
.myhibernatedata 490B
共 99 条
- 1
资源评论
- zdd4192013-05-03看完整个项目让我对webwork的理解又深了一层次,谢谢作者了。
thinkofme
- 粉丝: 2
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功