package com.cuikaixuan.hp.annoth.dao.impl;

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 org.springframework.stereotype.Repository;

import com.cuikaixuan.hp.annoth.dao.IAnnothDAO;
import com.cuikaixuan.hp.annoth.entity.Annoth;

/**
 * A data access object (DAO) providing persistence and search support for
 * Annoth 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 com.cuikaixuan.hp.annoth.entity.Annoth
 * @author MyEclipse Persistence Tools
 */
@Repository
public class AnnothDAOimpl extends BaseDao implements IAnnothDAO {
	private static final Log log = LogFactory.getLog(AnnothDAOimpl.class);
	protected void initDao() {
		// do nothing
	}

	/* (non-Javadoc)
	 * @see com.cuikaixuan.hp.annoth.dao.impl.IAnnothDAO#save(com.cuikaixuan.hp.annoth.entity.Annoth)
	 */
	public void save(Annoth transientInstance) {
		log.debug("saving Annoth instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.cuikaixuan.hp.annoth.dao.impl.IAnnothDAO#delete(com.cuikaixuan.hp.annoth.entity.Annoth)
	 */
	public void delete(Annoth persistentInstance) {
		log.debug("deleting Annoth instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.cuikaixuan.hp.annoth.dao.impl.IAnnothDAO#findById(java.lang.Integer)
	 */
	public Annoth findById(java.lang.Integer id) {
		log.debug("getting Annoth instance with id: " + id);
		try {
			Annoth instance = (Annoth) getHibernateTemplate().get(
					"com.cuikaixuan.hp.annoth.entity.Annoth", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.cuikaixuan.hp.annoth.dao.impl.IAnnothDAO#findByExample(com.cuikaixuan.hp.annoth.entity.Annoth)
	 */
	public List<Annoth> findByExample(Annoth instance) {
		log.debug("finding Annoth instance by example");
		try {
			List<Annoth> results = (List<Annoth>) 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 com.cuikaixuan.hp.annoth.dao.impl.IAnnothDAO#findByProperty(java.lang.String, java.lang.Object)
	 */
	public List findByProperty(String propertyName, Object value) {
		log.debug("finding Annoth instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from Annoth 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 com.cuikaixuan.hp.annoth.dao.impl.IAnnothDAO#findByAname(java.lang.Object)
	 */
	public List<Annoth> findByAname(Object aname) {
		return findByProperty(ANAME, aname);
	}

	/* (non-Javadoc)
	 * @see com.cuikaixuan.hp.annoth.dao.impl.IAnnothDAO#findAll()
	 */
	public List findAll() {
		log.debug("finding all Annoth instances");
		try {
			String queryString = "from Annoth";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.cuikaixuan.hp.annoth.dao.impl.IAnnothDAO#merge(com.cuikaixuan.hp.annoth.entity.Annoth)
	 */
	public Annoth merge(Annoth detachedInstance) {
		log.debug("merging Annoth instance");
		try {
			Annoth result = (Annoth) getHibernateTemplate().merge(
					detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.cuikaixuan.hp.annoth.dao.impl.IAnnothDAO#attachDirty(com.cuikaixuan.hp.annoth.entity.Annoth)
	 */
	public void attachDirty(Annoth instance) {
		log.debug("attaching dirty Annoth instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.cuikaixuan.hp.annoth.dao.impl.IAnnothDAO#attachClean(com.cuikaixuan.hp.annoth.entity.Annoth)
	 */
	public void attachClean(Annoth instance) {
		log.debug("attaching clean Annoth instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public static IAnnothDAO getFromApplicationContext(ApplicationContext ctx) {
		return (IAnnothDAO) ctx.getBean("AnnothDAO");
	}
}
最近下载更多
小王wang  LV10 8月15日
uuuuuuuuuuuwwwwww  LV3 2021年12月14日
dingyue  LV2 2021年12月5日
漫长的白日梦  LV8 2021年12月4日
lsglsg9  LV21 2021年11月24日
yexiansheng  LV1 2021年11月6日
GD_chan  LV5 2021年7月20日
yu  LV1 2021年6月24日
qweqweqwe7987987  LV1 2021年6月22日
1973356987  LV13 2021年6月9日
最近浏览更多
杜芋头 11月9日
暂无贡献等级
小王wang  LV10 8月15日
189676630  LV4 7月10日
gxlgxl  LV4 5月25日
taoxu01  LV1 5月24日
17787885952  LV3 5月5日
981352576  LV4 5月3日
yanguobin  LV4 5月3日
泰勒 斯威夫特  LV5 1月24日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友