📄 waredao.java
字号:
package com.hz.goods.dao;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import com.hz.hibernate.HibernateSessionFactory;
import com.hz.hibernate.PublicClass;
import com.hz.pojo.Ware;
public class WareDAO extends PublicClass implements IWareDAO {
public void deleteWarefindById(String[] ids) {
this.delete("Ware","wareId", ids);
}
public List queryWare(int pageNo, int perPageCount) {
Session session=HibernateSessionFactory.getSessionFactory().openSession();
Query query=session.createQuery("from Goods");
query.list();
query=session.createQuery("from Ware order by wareId desc");
int beginIndex=(pageNo-1)*perPageCount;
query.setFirstResult(beginIndex);
query.setMaxResults(perPageCount);
List list=query.list();
session.close();
return list;
}
public void addWare(Ware ware) {
super.insert(ware);
}
public void updateWare(Ware ware) {
this.update(ware);
}
public int getWareTatalCount() {
return this.queryRowCount("Goods","Ware");
}
public List queryGoods() {
List list=this.queryAll("Goods");
return list;
}
public Ware queryWareById(String wareId) {
Session session=HibernateSessionFactory.getSessionFactory().openSession();
Query query=session.createQuery("from Goods");
query.list();
query=session.createQuery("from Ware where wareId=?");
query.setString(0, wareId);
List list=query.list();
if(list.size()>0){
return (Ware)list.get(0);
}
session.close();
return null;
}
public boolean queryWareByWareName(String wareName,String goodsId) {
Session session=HibernateSessionFactory.getSessionFactory().openSession();
Query query=session.createQuery("from Goods");
query.list();
query=session.createQuery("from Ware where wareName=? and goodsId=?");
query.setString(0,wareName);
query.setString(1,goodsId);
List list=query.list();
if(list.size()>0){
return true;
}
session.close();
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -