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

📄 houselevconfigdao.java

📁 有关医院方向的开发
💻 JAVA
字号:
package com.woyi.dao;
// default package

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.*;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.woyi.dto.HouseLevConfig;

/**
 * A data access object (DAO) providing persistence and search support for
 * HouseLevConfig 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 .HouseLevConfig
 * @author MyEclipse Persistence Tools
 */

public class HouseLevConfigDAO extends HibernateDaoSupport {
	private static final Log log = LogFactory.getLog(HouseLevConfigDAO.class);
	// property constants
	public static final String HOUSELEVCONFIG_NAME = "houselevconfigName";
	public static final String LEVLTYPE = "levltype";
	public static final String LEVID = "levid";
	public static final String LEVNAME = "levname";
	public static final String ALLNAME = "allname";
	public static final String LEVEL = "level";
	public static final String LEVLACTION = "levlaction";
	public static final String PARENTLEVL_ID = "parentlevlId";
	public static final String ISLEAF = "isleaf";
	public static final String DISPLAYORDER = "displayorder";

	protected void initDao() {
		// do nothing
	}

	public boolean save(HouseLevConfig transientInstance) {
		log.debug("saving HouseLevConfig instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
			return true;
		} catch (RuntimeException re) {
			log.error("save failed", re);
			return false;
		}
	}

	public boolean delete(HouseLevConfig persistentInstance) {
		log.debug("deleting HouseLevConfig instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
			return true;
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			return false;
		}
	}
	/*
	 * 根据配置表中的接点类型模糊删除所有子节点
	 */
	public void deletebylevlid(String levlid) {
		
    	Session session = getHibernateTemplate().getSessionFactory().openSession();
    	Transaction tx = session.beginTransaction();
        try {
        	/*测试下批量删除*/
        	levlid = levlid+"%";
        	String sql = "delete from T_sp_houselevconfig a where a.levid like :levid";
        	session.createQuery(sql).setString("levid", levlid).executeUpdate();
        	tx.commit();
        	session.close();
            String delString = "from HouseLevConfig as a where a.levid like '"+levlid+"'" ;
            getHibernateTemplate().delete(delString);
         } catch (RuntimeException re) {
        	 tx.rollback();
        	 session.close();
            log.error("find by property name failed", re);
            throw re;
         }
	}
	
	public HouseLevConfig findById(java.lang.Integer id) {
		log.debug("getting HouseLevConfig instance with id: " + id);
		try {
			HouseLevConfig instance = (HouseLevConfig) getHibernateTemplate()
					.get("HouseLevConfig", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(HouseLevConfig instance) {
		log.debug("finding HouseLevConfig 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 HouseLevConfig instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from HouseLevConfig as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByHouselevconfigName(Object houselevconfigName) {
		return findByProperty(HOUSELEVCONFIG_NAME, houselevconfigName);
	}

	public List findByLevltype(Object levltype) {
		return findByProperty(LEVLTYPE, levltype);
	}

	public List findByLevid(Object levid) {
		return findByProperty(LEVID, levid);
	}

	public List findByLevname(Object levname) {
		return findByProperty(LEVNAME, levname);
	}

	public List findByLevel(Object level) {
		return findByProperty(LEVEL, level);
	}

	public List findByLevlaction(Object levlaction) {
		return findByProperty(LEVLACTION, levlaction);
	}

	public List findByParentlevlId(Object parentlevlId) {
		return findByProperty(PARENTLEVL_ID, parentlevlId);
	}

	public List findByIsleaf(Object isleaf) {
		return findByProperty(ISLEAF, isleaf);
	}

	public List findByDisplayorder(Object displayorder) {
		return findByProperty(DISPLAYORDER, displayorder);
	}

	public List findAll() {
		log.debug("finding all HouseLevConfig instances");
		try {
			String queryString = "from HouseLevConfig";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

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

	public boolean attachDirty(HouseLevConfig instance) {
		log.debug("attaching dirty HouseLevConfig instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
			return true;
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			return false;
		}
	}

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

	public static HouseLevConfigDAO getFromApplicationContext(
			ApplicationContext ctx) {
		return (HouseLevConfigDAO) ctx.getBean("HouseLevConfigDAO");
	}
	
	/* 
	 * 获取菜单
	 * 
	 */
	public List getlevlmenu()
	{

        try {
           String queryString = "from HouseLevConfig as a  order by a.levid";
  		 return getHibernateTemplate().find(queryString);
        } catch (RuntimeException re) {
           log.error("find by property name failed", re);
           throw re;
        }
	}
	/*
	 * 根据级别获取对应接点的详细信息
	 */
	public List getLevlInfoBylevl(String levl)
	{
        try {
            String queryString = "from HouseAreaInfo as a where a.levid in(select b.levid from HouseLevConfig as b where b.level='"+levl+"')";
   		 return getHibernateTemplate().find(queryString);
         } catch (RuntimeException re) {
            log.error("find by property name failed", re);
            throw re;
         }
	}
	/*
	 * 根据级别类型关联获取对应接点的详细信息
	 */
	public List getLevlInfoBylevlid(String levlid)
	{
        try {
            String queryString = "from HouseAreaInfo as a where a.levid in(select b.levid from HouseLevConfig as b where b.levid='"+levlid+"')";
   		 return getHibernateTemplate().find(queryString);
         } catch (RuntimeException re) {
            log.error("find by property name failed", re);
            throw re;
         }
	}
	/*
	 * 根据级别获取该接点下的所有信息
	 */
	public List GetgeneralLevlConfigInfoByLevlid(String levlid)
	{
        try {
            String queryString = "from HouseLevConfig as a where a.levid like'"+levlid+"%')";
   		 return getHibernateTemplate().find(queryString);
         } catch (RuntimeException re) {
            log.error("find by property name failed", re);
            throw re;
         }
	}
	/*
	 * 根据级别ID获取该接点下的所有详细信息
	 */
	public List GetgeneralareainfobyLevid(String levlid)
	{
        try {
            String queryString = "from HouseAreaInfo as a where a.levid like '"+levlid+"%')";
   		 return getHibernateTemplate().find(queryString);
         } catch (RuntimeException re) {
            log.error("find by property name failed", re);
            throw re;
         }
	}
	/*
	 * 根据级别ID查询对应的配置信息
	 */
	public List getLevConfigInfoBylevlid(String levlid)
	{
        try {
            String queryString = "from HouseLevConfig as a where a.levid ='"+levlid+"'";
   		 return getHibernateTemplate().find(queryString);
         } catch (RuntimeException re) {
            log.error("find by property name failed", re);
            throw re;
         }
	}
}

⌨️ 快捷键说明

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