categorydaoimpl.java

来自「hibernate 简单的例子」· Java 代码 · 共 44 行

JAVA
44
字号
package org.itfuture.www.dao.impl;

import java.util.List;

import org.itfuture.www.dao.CategoryDao;
import org.itfuture.www.po.Category;
import org.itfuture.www.po.Item;
import org.itfuture.www.po.Product;

import www.hibernate.util.method.DaoSupport;

public class CategoryDaoImpl extends DaoSupport implements CategoryDao {
	// 得到所有商品类别信息
	public List<Category> getCategory() {

		List list = this.getHibernateTemplate().query("from Category A", null);
		return list;
	}

	// 得到某个类别下的所有商品信息
	public List<Product> getProduct(String catid) {

		return this.getHibernateTemplate().query(
				"from Product A where A.category.catid=?",
				new String[] { catid });
	}

	// 得到一个商品编号下的所有商品信息
	public List<Item> getItem(String productid) {

		return this.getHibernateTemplate().query(
				"from Item A where A.product.productid=?",
				new String[] { productid });
	}

	// 得到一个具体的商品信息
	public Item getOneItem(String itemid) {
		List<Item> list = this.getHibernateTemplate().query(
				"from Item A where A.itemid=?", new String[] { itemid });
		return list.get(0);
	}

}

⌨️ 快捷键说明

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