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");
	}
}
最近下载更多
15828038591  LV11 12月17日
张真狗  LV9 2023年5月22日
小王wang  LV10 2022年8月15日
uuuuuuuuuuuwwwwww  LV3 2021年12月14日
dingyue  LV2 2021年12月5日
漫长的白日梦  LV8 2021年12月4日
lsglsg9  LV23 2021年11月24日
yexiansheng  LV1 2021年11月6日
GD_chan  LV5 2021年7月20日
yu  LV1 2021年6月24日
最近浏览更多
15828038591  LV11 12月17日
lyt010628  LV4 2024年7月9日
y_x_happy  LV4 2024年6月25日
dsffssff  LV4 2024年6月9日
asddwh  LV13 2023年12月25日
WBelong  LV8 2023年12月18日
zdfxcv  LV1 2023年10月14日
80730176  LV7 2023年10月11日
wanglei92  LV2 2023年6月26日
yemmmm666  LV1 2023年6月12日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友