SpringDAO
上一篇 /
下一篇 2008-03-08 11:23:33 / 天气: 晴朗
/ 心情: 高兴
/ 精华(1)
/ 个人分类:知道
你好!
请问我这个DAO中红色的方法是用来做什么的呀?(我这个DAO的方法是SPRING框架生成的)
package com.dao.imp;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.criterion.Example;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.dao.IVideDownloadDAO;
import db.VideoDownload;
/**
* Data access object (DAO) for domain model class VideoDownload.
* @see db.VideoDownload
* @author MyEclipse - Hibernate Tools
*/
public class VideoDownloadDAO extends HibernateDaoSupport implements IVideDownloadDAO {
private static final Log log = LogFactory.getLog(VideoDownloadDAO.class);
protected void initDao() {
//do nothing
}
/* (非 Javadoc)
* @see com.dao.imp.IVideDownloadDAO#save(db.VideoDownload)
*/
public void save(VideoDownload transientInstance) {
log.debug("saving VideoDownload instance");
try {
getHibernateTemplate().saveOrUpdate(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
/* (非 Javadoc)
* @see com.dao.imp.IVideDownloadDAO#delete(db.VideoDownload)
*/
public void delete(VideoDownload persistentInstance) {
log.debug("deleting VideoDownload instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
/* (非 Javadoc)
* @see com.dao.imp.IVideDownloadDAO#findById(java.lang.String)
*/
public VideoDownload findById( java.lang.String id) {
log.debug("getting VideoDownload instance with id: " + id);
try {
VideoDownload instance = (VideoDownload) getHibernateTemplate()
.get("db.VideoDownload", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
/* (非 Javadoc)
* @see com.dao.imp.IVideDownloadDAO#findByExample(db.VideoDownload)
*/
public List findByExample(VideoDownload instance) {
log.debug("finding VideoDownload instance by example");
try {
List results = getSession()
.createCriteria("db.VideoDownload")
.add(Example.create(instance))
.list();
log.debug("find by example successful, result size: " + results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
/* (非 Javadoc)
* @see com.dao.imp.IVideDownloadDAO#merge(db.VideoDownload)
*/
public VideoDownload merge(VideoDownload detachedInstance) {
log.debug("merging VideoDownload instance");
try {
VideoDownload result = (VideoDownload) getHibernateTemplate()
.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
/* (非 Javadoc)
* @see com.dao.imp.IVideDownloadDAO#attachDirty(db.VideoDownload)
*/
public void attachDirty(VideoDownload instance) {
log.debug("attaching dirty VideoDownload instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
/* (非 Javadoc)
* @see com.dao.imp.IVideDownloadDAO#attachClean(db.VideoDownload)
*/
public void attachClean(VideoDownload instance){
log.debug("attaching clean VideoDownload instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public static IVideDownloadDAO getFromApplicationContext(ApplicationContext ctx) {
return (IVideDownloadDAO) ctx.getBean("VideoDownloadDAO");
}
}
导入论坛
引用链接
收藏
分享给好友
推荐到圈子
管理
举报
TAG: