auctionitemsdaoimpl.java

来自「Struts+Spring+Hibernate实现的在线拍卖系统,去掉了这些组件」· Java 代码 · 共 98 行

JAVA
98
字号
package org.bestteam.dao.impl;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.bestteam.dao.AuctionItemsDao;
import org.bestteam.domain.AuctionItems;
import org.bestteam.domain.Catalog;
import org.bestteam.domain.MerchandiseInfo;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class AuctionItemsDaoImpl extends HibernateDaoSupport implements
		AuctionItemsDao {

	private static final Log log = LogFactory.getLog(AuctionItemsDao.class);

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

	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding AuctionItems instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from AuctionItems where " + propertyName
					+ "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

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

	}

	public AuctionItems saveOrUpdate(AuctionItems auctionItems) {
		log.debug("saveOrUpdate Catalog instance");
		try {
			AuctionItems result = (AuctionItems) getHibernateTemplate().merge(
					auctionItems);
			log.debug("saveOrUpdate successful");
			return result;
		} catch (RuntimeException re) {
			log.error("saveOrUpdate failed", re);
			throw re;
		}
	}

	public List getAllAuctionItem() {
		log.debug("finding AuctionItems instance");
		try {
			String queryString = "from AuctionItems";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List getAllAuctionItem(int from, int size, int catalogID) {
		List list = getSession()
				.createQuery(
						"from MerchandiseInfo as mer where mer.auctionItems.state='T' and mer.catalog.catalogId="
								+ catalogID).setFirstResult(from)
				.setMaxResults(size).list();
		return list;
	}

	public List getAllAuctionItem(int catalogID) {
		List list = getSession()
				.createQuery(
						"from MerchandiseInfo as mer where mer.auctionItems.state='T' and mer.catalog.catalogId="
								+ catalogID).list();
		return list;
	}

}

⌨️ 快捷键说明

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