⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 .#businessdaohibernate.java.1.6

📁 这个是完整的wap项目的源码 开发语言 Java 系统架构 Struts + hibernate + spring 数据库 Mysql5.0 应用服务器Tomcat5.0 开发工具 MyEc
💻 6
字号:
package com.longtime.wap.module.information.dao.hibernate;

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

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.longtime.wap.common.BaseDao;
import com.longtime.wap.model.Business;
import com.longtime.wap.module.information.dao.BusinessDao;

/**
 * 定义对business的持久化类进行操作的接口
 * 
 * @author Bulc
 * @date Nov 19, 2007
 */
public class BusinessDaoHibernate extends BaseDao implements BusinessDao {
	
	/**
	 * 根据信息发布商id,查询业务列表
	 * 
	 * @param cpId
	 *            信息发布商id
	 * @return 查询业务列表
	 */
	public List getBusinesses(final Long cpId) {
		return this.getHibernateTemplate().executeFind(new HibernateCallback() {
			public Object doInHibernate(Session session)
					throws HibernateException, SQLException {
				StringBuilder hql = new StringBuilder();
				hql.append("from Business business");
				if (null != cpId) {
					hql.append(" where business.cp.cpId=? order by business.businessId asc");
				}
				Query query = session.createQuery(hql.toString());
				if (null != cpId) {
					query.setLong(0, cpId);
				}
				return query.list();
			}
		});
	}

	/**
	 * 根据业务id,查询业务
	 * 
	 * @param id
	 *            业务id
	 * @return 业务对象
	 */
	public Business getBusinessById(Long id) {
		return (Business) this.getHibernateTemplate().get(Business.class, id);
	}

}

⌨️ 快捷键说明

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