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

📄 pricedaoimpl.java

📁 电信计费项目 该系统在Sun Solaris下开发,运行于Apache Tomcat平台,采用J2EE架构
💻 JAVA
字号:
package com.tarena.netctoss.model.persist;import java.util.List;import org.hibernate.*;import com.tarena.util.*;import com.tarena.netctoss.model.biz.entity.Price;public class PriceDAOImpl implements IPriceDAO {	public void delete(Price price) throws PriceException{		Session session = HibernateFactoryManager.getSession();		try {			session.delete(price);		} catch (HibernateException e) {			e.printStackTrace();			throw new PriceException("delete Priceerror");		}	}	@SuppressWarnings("unchecked")	public List<Price> findAll() throws PriceException{		Session session = HibernateFactoryManager.getSession();		List<Price> prices = null;		String hql = "from Price";		try {			Query q = session.createQuery(hql);			prices = q.list();		} catch (HibernateException e) {			e.printStackTrace();			throw new PriceException("find all Price error");		}		return prices;	}	public void insert(Price price) throws PriceException{		Session session = HibernateFactoryManager.getSession();		try {			session.save(price);                        System.out.println("insert service");		} catch (HibernateException e) {			e.printStackTrace();			throw new PriceException("insert Price error");		}	} 	public void update(Price price) throws PriceException{		Session session = HibernateFactoryManager.getSession();		try {			Price p = findByID(price.getPrice_id());			p.setPrice_name(price.getPrice_name());			p.setPrice_descripte(price.getPrice_descripte());			p.setBase_fee(price.getBase_fee());			p.setRate_fee(price.getRate_fee());			session.update(p);		} catch (HibernateException e) {			e.printStackTrace();			throw new PriceException("update Price error");		}	}		public Price findByID(Long price_id) throws PriceException{		Price price = null;		Session session = HibernateFactoryManager.getSession();		String hql = "from Price price where price.price_id=?";		try {			Query q = session.createQuery(hql);			q.setLong(0, price_id);			price = (Price) q.uniqueResult();		} catch (HibernateException e) {			e.printStackTrace();			throw new PriceException("find by id Price error");		}		return price;	}		public Price findByName(String price_name) throws PriceException{		Price price = null;		Session session = HibernateFactoryManager.getSession();		String hql = "from Price price where price.price_name=?";		try {			Query q = session.createQuery(hql);			q.setString(0, price_name);			price = (Price) q.uniqueResult();		} catch (HibernateException e) {			e.printStackTrace();			throw new PriceException("find by id Price error");		}		return price;	}}

⌨️ 快捷键说明

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