package dao; import java.util.List; import models.Admin; import org.hibernate.LockMode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; /** * A data access object (DAO) providing persistence and search support for Admin 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 models.Admin * @author MyEclipse Persistence Tools */ public class AdminDAO extends HibernateDaoSupport implements IAdminDAO { private static final Logger log = LoggerFactory.getLogger(AdminDAO.class); protected void initDao() { //do nothing } /* (non-Javadoc) * @see dao.IAdminDAO#save(models.Admin) */ public void save(Admin transientInstance) { log.debug("saving Admin instance"); try { getHibernateTemplate().save(transientInstance); log.debug("save successful"); } catch (RuntimeException re) { log.error("save failed", re); throw re; } } /* (non-Javadoc) * @see dao.IAdminDAO#delete(models.Admin) */ public void delete(Admin persistentInstance) { log.debug("deleting Admin instance"); try { getHibernateTemplate().delete(persistentInstance); log.debug("delete successful"); } catch (RuntimeException re) { log.error("delete failed", re); throw re; } } /* (non-Javadoc) * @see dao.IAdminDAO#findById(java.lang.Integer) */ public Admin findById( java.lang.Integer id) { log.debug("getting Admin instance with id: " + id); try { Admin instance = (Admin) getHibernateTemplate() .get("models.Admin", id); return instance; } catch (RuntimeException re) { log.error("get failed", re); throw re; } } /* (non-Javadoc) * @see dao.IAdminDAO#findByExample(models.Admin) */ public List findByExample(Admin instance) { log.debug("finding Admin 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; } } /* (non-Javadoc) * @see dao.IAdminDAO#findByProperty(java.lang.String, java.lang.Object) */ public List findByProperty(String propertyName, Object value) { log.debug("finding Admin instance with property: " + propertyName + ", value: " + value); try { String queryString = "from Admin 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 dao.IAdminDAO#findByAdminId(java.lang.Object) */ public List findByAdminId(Object adminId ) { return findByProperty(ADMIN_ID, adminId ); } /* (non-Javadoc) * @see dao.IAdminDAO#findByAdminName(java.lang.Object) */ public List findByAdminName(Object adminName ) { return findByProperty(ADMIN_NAME, adminName ); } /* (non-Javadoc) * @see dao.IAdminDAO#findByAdminPs(java.lang.Object) */ public List findByAdminPs(Object adminPs ) { return findByProperty(ADMIN_PS, adminPs ); } /* (non-Javadoc) * @see dao.IAdminDAO#findAll() */ public List findAll() { log.debug("finding all Admin instances"); try { String queryString = "from Admin"; return getHibernateTemplate().find(queryString); } catch (RuntimeException re) { log.error("find all failed", re); throw re; } } /* (non-Javadoc) * @see dao.IAdminDAO#merge(models.Admin) */ public Admin merge(Admin detachedInstance) { log.debug("merging Admin instance"); try { Admin result = (Admin) getHibernateTemplate() .merge(detachedInstance); log.debug("merge successful"); return result; } catch (RuntimeException re) { log.error("merge failed", re); throw re; } } /* (non-Javadoc) * @see dao.IAdminDAO#attachDirty(models.Admin) */ public void attachDirty(Admin instance) { log.debug("attaching dirty Admin instance"); try { getHibernateTemplate().saveOrUpdate(instance); log.debug("attach successful"); } catch (RuntimeException re) { log.error("attach failed", re); throw re; } } /* (non-Javadoc) * @see dao.IAdminDAO#attachClean(models.Admin) */ public void attachClean(Admin instance) { log.debug("attaching clean Admin instance"); try { getHibernateTemplate().lock(instance, LockMode.NONE); log.debug("attach successful"); } catch (RuntimeException re) { log.error("attach failed", re); throw re; } } public static IAdminDAO getFromApplicationContext(ApplicationContext ctx) { return (IAdminDAO) ctx.getBean("AdminDAO"); } }

krispeng LV15
6月1日
571818771 LV3
2024年12月17日
星予宝藏666 LV6
2023年5月27日
海棠花瘦 LV9
2023年5月5日
aaa最代码 LV14
2023年2月27日
LITIANYU084414 LV11
2022年12月30日
weilaizhisheng LV21
2022年12月5日
yut1an LV2
2022年10月31日
hdwangxin LV1
2022年7月7日
bluesky2016 LV15
2022年7月6日

微信网友_7407113009926144 LV1
3月2日
微信网友_7391151377240064
2月19日
暂无贡献等级
ma406805131 LV19
2024年12月26日
571818771 LV3
2024年12月17日
AOAO1234 LV2
2024年12月12日
xuanwomingren
2024年12月9日
暂无贡献等级
liulian666 LV2
2024年7月19日
y_x_happy LV4
2024年6月7日
sunlea LV20
2024年5月17日
阿昌先生 LV13
2024年3月26日