orderlistdao.java

来自「一套自己原先在学校作的CRM,大家指点下」· Java 代码 · 共 160 行

JAVA
160
字号
package com.crm.dao;

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 com.crm.pojo.OrderList;

/**
 * Data access object (DAO) for domain model class OrderList.
 * 
 * @see com.crm.pojo.OrderList
 * @author MyEclipse Persistence Tools
 */

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

	// property constants
	public static final String LIST_PRODUCT_ID = "listProductId";

	public static final String LIST_QUANTITY = "listQuantity";

	public static final String LIST_MONEY = "listMoney";

	public static final String LIST_ORDER_ID = "listOrderId";

	protected void initDao() {
		// do nothing
	}

	public void save(OrderList transientInstance) {
		log.debug("saving OrderList instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(OrderList persistentInstance) {
		log.debug("deleting OrderList instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

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

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

	public List findByListQuantity(Object listQuantity) {
		return findByProperty(LIST_QUANTITY, listQuantity);
	}

	public List findByListMoney(Object listMoney) {
		return findByProperty(LIST_MONEY, listMoney);
	}

	public List findByListOrderId(Object listOrderId) {
		return findByProperty(LIST_ORDER_ID, listOrderId);
	}

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

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

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

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

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

⌨️ 快捷键说明

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