⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 archivesdao.java

📁 本项目源码是一个真实的应用项目
💻 JAVA
字号:
package org.langsin.computer.dao.impl;

import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.langsin.computer.vo.Archives;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 * Data access object (DAO) for domain model class Archives.
 * @see org.langsin.computer.vo.Archives
 * @author MyEclipse - Hibernate Tools
 */
public class ArchivesDAO extends HibernateDaoSupport {

    private static final Log log = LogFactory.getLog(ArchivesDAO.class);

	//property constants

	protected void initDao() {
		//do nothing
	}
    
    public void save(Archives transientInstance) {
        log.debug("saving Archives instance");
        try {
            getHibernateTemplate().save(transientInstance);
            log.debug("save successful");
        } catch (RuntimeException re) {
            log.error("save failed", re);
            throw re;
        }
    }
    
	public void delete(Archives persistentInstance) {
        log.debug("deleting Archives instance");
        try {
            getHibernateTemplate().delete(persistentInstance);
            log.debug("delete successful");
        } catch (RuntimeException re) {
            log.error("delete failed", re);
            throw re;
        }
    }
    
    public Archives findById( java.lang.Integer id) {
        log.debug("getting Archives instance with id: " + id);
        try {
            Archives instance = (Archives) getHibernateTemplate()
                    .get("org.langsin.computer.vo.Archives", id);
            return instance;
        } catch (RuntimeException re) {
            log.error("get failed", re);
            throw re;
        }
    }
    
    
    public List findByExample(Archives instance) {
        log.debug("finding Archives 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 Archives instance with property: " + propertyName
            + ", value: " + value);
      try {
         String queryString = "from Archives as model where model." 
         						+ propertyName + "= ?";
		 return getHibernateTemplate().find(queryString, value);
      } catch (RuntimeException re) {
         log.error("find by property name failed", re);
         throw re;
      }
	}

    public Archives merge(Archives detachedInstance) {
        log.debug("merging Archives instance");
        try {
            Archives result = (Archives) getHibernateTemplate()
                    .merge(detachedInstance);
            log.debug("merge successful");
            return result;
        } catch (RuntimeException re) {
            log.error("merge failed", re);
            throw re;
        }
    }

    public void attachDirty(Archives instance) {
        log.debug("attaching dirty Archives instance");
        try {
            getHibernateTemplate().saveOrUpdate(instance);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }
    
    public void attachClean(Archives instance) {
        log.debug("attaching clean Archives instance");
        try {
            getHibernateTemplate().lock(instance, LockMode.NONE);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }

	public static ArchivesDAO getFromApplicationContext(ApplicationContext ctx) {
    	return (ArchivesDAO) ctx.getBean("ArchivesDAO");
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -