package taotao.montao.emp.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 taotao.montao.emp.vo.EmpVO;
/**
* A data access object (DAO) providing persistence and search support for EmpVO 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 taotao.montao.emp.vo.EmpVO
* @author MyEclipse Persistence Tools
*/
public class EmpDAOImpl extends HibernateDaoSupport implements IEmpDAO {
private static final Log log = LogFactory.getLog(EmpDAOImpl.class);
//property constants
public static final String NAME = "name";
public static final String EMAIL = "email";
public static final String TEL = "tel";
public static final String ADDRESS = "address";
protected void initDao() {
//do nothing
}
/* (non-Javadoc)
* @see taotao.montao.emp.dao.IEmpDAO#save(taotao.montao.emp.vo.EmpVO)
*/
public void save(EmpVO transientInstance) {
log.debug("saving EmpVO instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
/* (non-Javadoc)
* @see taotao.montao.emp.dao.IEmpDAO#delete(taotao.montao.emp.vo.EmpVO)
*/
public void delete(EmpVO persistentInstance) {
log.debug("deleting EmpVO instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
/* (non-Javadoc)
* @see taotao.montao.emp.dao.IEmpDAO#findById(java.lang.Integer)
*/
public EmpVO findById( java.lang.Integer id) {
log.debug("getting EmpVO instance with id: " + id);
try {
EmpVO instance = (EmpVO) getHibernateTemplate()
.get("taotao.montao.emp.vo.EmpVO", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
/* (non-Javadoc)
* @see taotao.montao.emp.dao.IEmpDAO#findByExample(taotao.montao.emp.vo.EmpVO)
*/
@SuppressWarnings("unchecked")
public List findByExample(EmpVO instance) {
log.debug("finding EmpVO 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 taotao.montao.emp.dao.IEmpDAO#findByProperty(java.lang.String, java.lang.Object)
*/
@SuppressWarnings("unchecked")
public List findByProperty(String propertyName, Object value) {
log.debug("finding EmpVO instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from EmpVO 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 taotao.montao.emp.dao.IEmpDAO#findByName(java.lang.Object)
*/
@SuppressWarnings("unchecked")
public List findByName(Object name
) {
return findByProperty(NAME, name
);
}
/* (non-Javadoc)
* @see taotao.montao.emp.dao.IEmpDAO#findByEmail(java.lang.Object)
*/
@SuppressWarnings("unchecked")
public List findByEmail(Object email
) {
return findByProperty(EMAIL, email
);
}
/* (non-Javadoc)
* @see taotao.montao.emp.dao.IEmpDAO#findByTel(java.lang.Object)
*/
@SuppressWarnings("unchecked")
public List findByTel(Object tel
) {
return findByProperty(TEL, tel
);
}
/* (non-Javadoc)
* @see taotao.montao.emp.dao.IEmpDAO#findByAddress(java.lang.Object)
*/
@SuppressWarnings("unchecked")
public List findByAddress(Object address
) {
return findByProperty(ADDRESS, address
);
}
/* (non-Javadoc)
* @see taotao.montao.emp.dao.IEmpDAO#findAll()
*/
@SuppressWarnings("unchecked")
public List findAll() {
log.debug("finding all EmpVO instances");
try {
String queryString = "from EmpVO";
return getHibernateTemplate().find(queryString);
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
/* (non-Javadoc)
* @see taotao.montao.emp.dao.IEmpDAO#merge(taotao.montao.emp.vo.EmpVO)
*/
public EmpVO merge(EmpVO detachedInstance) {
log.debug("merging EmpVO instance");
try {
EmpVO result = (EmpVO) getHibernateTemplate()
.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
/* (non-Javadoc)
* @see taotao.montao.emp.dao.IEmpDAO#attachDirty(taotao.montao.emp.vo.EmpVO)
*/
public void attachDirty(EmpVO instance) {
log.debug("attaching dirty EmpVO instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
/* (non-Javadoc)
* @see taotao.montao.emp.dao.IEmpDAO#attachClean(taotao.montao.emp.vo.EmpVO)
*/
public void attachClean(EmpVO instance) {
log.debug("attaching clean EmpVO instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static IEmpDAO getFromApplicationContext(ApplicationContext ctx) {
return (IEmpDAO) ctx.getBean("EmpVODAO");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Struts+Spring+Hibernate实现的增删查该Demo(不带jar包).rar (72个子文件)
Struts+Spring+Hibernate实现的增删查该Demo(不带jar包)
mysshDemo
.project 2KB
dept
taotao
montao
dept
dao
IDeptDAO.java 1KB
DeptDAOImpl.java 6KB
action
DeptAction.java 6KB
DeptForm.java 709B
vo
DeptVO.hbm.xml 1KB
DeptVO.java 1KB
service
IDeptService.java 446B
DeptServiceImpl.java 1KB
.myumldata 66B
.settings
org.eclipse.core.resources.prefs 124B
.mymetadata 297B
emp
taotao
montao
emp
dao
EmpDAOImpl.java 7KB
IEmpDAO.java 1KB
action
EmpForm.java 944B
EmpAction.java 953B
vo
EmpVO.java 2KB
EmpVO.hbm.xml 1KB
service
IEmpService.java 427B
EmpServiceImpl.java 982B
.myeclipse
src
dbcon.properties 1KB
taotao
montao
tool
Init.java 1KB
dbcon
DBCon.java 2KB
applicationContext.xml 2KB
ApplicationResources.properties 69B
hibernate.cfg.xml 954B
hibernate.reveng.xml 608B
.mystrutsdata 240B
.springBeans 320B
.classpath 6KB
.myhibernatedata 513B
demo
WEB-INF
struts-tiles.tld 8KB
.struts-config.mex 2KB
web.xml 1KB
struts-config.xml 1KB
struts-bean.tld 9KB
struts-nested.tld 70KB
struts-html.tld 72KB
struts-logic.tld 14KB
validator-rules.xml 13KB
action-servlet.xml 818B
lib
classes
dbcon.properties 1KB
taotao
montao
dept
dao
DeptDAOImpl.class 6KB
IDeptDAO.class 908B
action
DeptAction.class 6KB
DeptForm.class 1KB
vo
DeptVO.class 2KB
DeptVO.hbm.xml 1KB
service
IDeptService.class 512B
DeptServiceImpl.class 2KB
emp
dao
IEmpDAO.class 695B
EmpDAOImpl.class 5KB
action
EmpForm.class 1KB
EmpAction.class 2KB
vo
EmpVO.hbm.xml 1KB
EmpVO.class 2KB
service
EmpServiceImpl.class 2KB
IEmpService.class 498B
tool
Init.class 2KB
dbcon
DBCon.class 2KB
applicationContext.xml 2KB
ApplicationResources.properties 69B
hibernate.cfg.xml 954B
dept
editDept.jsp 1KB
showDept.jsp 843B
deptList.jsp 2KB
deptNew.jsp 675B
META-INF
MANIFEST.MF 39B
emp
empNew.jsp 825B
error.jsp 265B
db
emp.sql 620B
dept.sql 2KB
共 72 条
- 1
资源评论
- superdemon2012-07-30这个用上了。。。可能大家需要稍微修改一下。
kone219
- 粉丝: 9
- 资源: 20
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功