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:

qingfengler的个人空间 引用 删除 qingfengler   /   2008-05-10 16:35:59
呵呵。。
现在问题解决了
MyEclipse6.0映射的是对象属性 不再是这些了
 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

我的栏目

日历

« 2008-10-16  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 90
  • 日志数: 3
  • 建立时间: 2008-03-08
  • 更新时间: 2008-08-25

RSS订阅

Open Toolbar