waredao.java

来自「本系统为符合订单管理 精确使用了账号分层用户管理 可进行主订单 次订单的增加 删」· Java 代码 · 共 80 行

JAVA
80
字号
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 + =
减小字号Ctrl + -
显示快捷键?