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

📄 goodsimpl.java

📁 这是一款最新的野蔷薇论坛源码,有需要的朋友可以尽情下载
💻 JAVA
字号:
/* 
 * Created on 2006-2-20
 * Last modified on 2007-1-21
 * Powered by YeQiangWei.com
 */
package com.yeqiangwei.club.dao.hibernate.impl;

import java.util.List;

import com.yeqiangwei.club.dao.GoodsDAO;
import com.yeqiangwei.club.dao.hibernate.support.HibernateFacade;
import com.yeqiangwei.club.dao.model.Goods;
import com.yeqiangwei.club.param.GoodsParameter;

public class GoodsImpl implements GoodsDAO{
	
	private static final String FIND_TYPE = "from Goods where type=?";
	
	private static final String FIND_GOODSID = "from Goods where goodsId=?";
	
	private static final String FIND_ALL = "from Goods order by type asc, goodsId desc";
	
	private static final String DELETE_GOODSID = "delete Goods where goodsId=?";
	
	private static final String DELETES_GOODSID = "delete Goods where goodsId in (:ids)";

	public Goods create(Goods item) {
		HibernateFacade<Goods> facade = new HibernateFacade<Goods>();
		item = facade.save(item);		
		return item;
	}

	public Goods update(Goods item) {
		HibernateFacade<Goods> facade = new HibernateFacade<Goods>();
		facade.update(item);
		return item;
	}

	public int delete(Goods item) {
		HibernateFacade<Goods> facade = new HibernateFacade<Goods>();
		facade.createQuery(DELETE_GOODSID);
		facade.setInt(0, item.getGoodsId());
		int c = facade.executeUpdate();
		return c;
	}

	public int delete(List ids) {
		HibernateFacade<Goods> facade = new HibernateFacade<Goods>();
		facade.createQuery(DELETES_GOODSID);
		facade.setParameterList("ids", ids);
		int c = facade.executeUpdate();
		return c;
	}

	public Goods findById(int id) {
		Goods item = null;
        HibernateFacade<Goods> facade = new HibernateFacade<Goods>(FIND_GOODSID);
        facade.setInt(0, id);
        facade.setCacheable(true); 
        facade.setMaxResults(1);
        item = facade.uniqueResult();
        return item;
	}

	public List<Goods> findByParameter(GoodsParameter param) {
		return null;
	}

	public long countByParameter(GoodsParameter param) {
		return 0;
	}

	public List findAll(GoodsParameter param) {
		List list = null;
		HibernateFacade facade = new HibernateFacade();
    	facade.createQuery(FIND_ALL);
        list = facade.executeQuery();  
		return list;
	}

	public long countAll(GoodsParameter param) {
		return 0;
	}

	public Goods findByType(byte type) {
		HibernateFacade facade = new HibernateFacade();
    	facade.createQuery(FIND_TYPE);
        facade.setMaxResults(1);
        Goods item = (Goods) facade.uniqueResult();
		return item;
	}
	
}

⌨️ 快捷键说明

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