📄 usergoodsimpl.java
字号:
/*
* Created on 2006-2-21
* 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.UserGoodsDAO;
import com.yeqiangwei.club.dao.hibernate.support.HibernateFacade;
import com.yeqiangwei.club.dao.model.UserGoods;
import com.yeqiangwei.club.param.GoodsParameter;
/**
*
* @author yeqiangwei
*/
public class UserGoodsImpl implements UserGoodsDAO {
private static final String FIND_USERGOODSID = "from UserGoods where userGoodsId=?";
private static final String DELETE_USERGOODSID = "delete from UserGoods where userGoodsId=?";
private static final String DELETES_USERGOODSID = "delete from UserGoods where userGoodsId in (:ids)";
public UserGoods create(UserGoods item) {
HibernateFacade<UserGoods> facade = new HibernateFacade<UserGoods>();
item = facade.save(item);
return item;
}
public UserGoods update(UserGoods item) {
HibernateFacade<UserGoods> facade = new HibernateFacade<UserGoods>();
item = facade.update(item);
return item;
}
public int delete(UserGoods item) {
HibernateFacade<UserGoods> facade = new HibernateFacade<UserGoods>();
facade.createQuery(DELETE_USERGOODSID);
facade.setInt(0,item.getGoodsId());
int c = facade.executeUpdate();
return c;
}
public int delete(List ids) {
HibernateFacade<UserGoods> facade = new HibernateFacade<UserGoods>();
facade.createQuery(DELETES_USERGOODSID);
facade.setParameterList("ids", ids);
int c = facade.executeUpdate();
return c;
}
public UserGoods findById(int id) {
HibernateFacade<UserGoods> facade = new HibernateFacade<UserGoods>();
facade.createQuery(FIND_USERGOODSID);
facade.setInt(0, id);
UserGoods item = (UserGoods) facade.uniqueResult();
return item;
}
public List<UserGoods> findByParameter(GoodsParameter param) {
StringBuffer hql = new StringBuffer();
hql.append("from UserGoods where userGoodsId>0");
if(param.getType()!=null){
hql.append(" and type=");
hql.append(param.getType().byteValue());
}
HibernateFacade<UserGoods> facade = new HibernateFacade<UserGoods>();
facade.createQuery(hql);
List<UserGoods> list = facade.executeQuery();
return list;
}
public long countByParameter(GoodsParameter param) {
StringBuffer hql = new StringBuffer();
hql.append("select count(userGoodsId) from UserGoods where userGoodsId>0");
if(param.getType()!=null){
hql.append(" and type=");
hql.append(param.getType().byteValue());
}
HibernateFacade<UserGoods> facade = new HibernateFacade<UserGoods>();
facade.createQuery(hql);
int c = facade.executeUpdate();
return c;
}
public List findAll(GoodsParameter param) {
return null;
}
public long countAll(GoodsParameter param) {
return 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -