src/gouwushangcheng/dao/impl/ProductDaoImpl.java

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

package gouwushangcheng.dao.impl;
import gouwushangcheng.dao.ProductDao;
import gouwushangcheng.model.Product;

import java.sql.SQLException;
import java.util.List;


import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;



public class ProductDaoImpl extends HibernateDaoSupport implements ProductDao {

	

	public void deleteBean(Product bean) {
		this.getHibernateTemplate().delete(bean);
		
	}

	public void insertBean(Product bean) {
		this.getHibernateTemplate().save(bean);
		
	}

	@SuppressWarnings("unchecked")
	public Product selectBean(String where) {
		List<Product> list = this.getHibernateTemplate().find("from Product "+where);
		if(list.size()==0){
			return null;
		}
		return list.get(0);
	}

	public long selectBeanCount(final String where) {
		long count = (Long)this.getHibernateTemplate().find(" select count(*) from Product  "+where).get(0);
		return count;
	}

	@SuppressWarnings("unchecked")
	public List<Product> selectBeanList(final int start,final int limit,final String where) {
		return (List<Product>)this.getHibernateTemplate().executeFind(new HibernateCallback(){

			public Object doInHibernate(final Session session) throws HibernateException, SQLException {
				List<Product> list = session.createQuery(" from Product"+where).setFirstResult(start).setMaxResults(limit).list();
				return list;
			}
		});
		
	}

	public void updateBean(Product bean) {
		this.getHibernateTemplate().update(bean);
		
	}
	
后面还有 7 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。