xssyscontroldao.java

来自「关于网上汽车销售系统的详细编程项目实战实例」· Java 代码 · 共 116 行

JAVA
116
字号
package com.company.hib.dao.impl;

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

import com.company.hib.dao.DAOAdapter;
import com.company.struts.form.XsSysControl;

/**
 * Data access object (DAO) for domain model class XsSysControl.
 * 
 * @see com.company.struts.form.XsSysControl
 * @author MyEclipse Persistence Tools
 */

public class XsSysControlDAO extends DAOAdapter {
	private static final Log log = LogFactory.getLog(XsSysControlDAO.class);

	// property constants
	public static final String SINVOICE_OR = "sinvoiceOr";

	public static final String SRETURN_OR = "sreturnOr";

	protected void initDao() {
		// do nothing
	}

	public ActionForm findById(java.lang.Integer id) {
		log.debug("getting XsSysControl instance with id: " + id);
		try {
			XsSysControl instance = (XsSysControl) getHibernateTemplate().get(
					"com.company.struts.form.XsSysControl", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(ActionForm instance) {
		log.debug("finding XsSysControl 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 XsSysControl instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from XsSysControl 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 findBySinvoiceOr(Object sinvoiceOr) {
		return findByProperty(SINVOICE_OR, sinvoiceOr);
	}

	public List findBySreturnOr(Object sreturnOr) {
		return findByProperty(SRETURN_OR, sreturnOr);
	}

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

	public void attachDirty(XsSysControl instance) {
		log.debug("attaching dirty XsSysControl instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

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

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

⌨️ 快捷键说明

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