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

📄 orderstatedao.java

📁 网上购物系统
💻 JAVA
字号:
package tarena.dao;

import org.hibernate.Session;

import tarena.entity.Orderstate;
public class OrderstateDAO extends BaseHibernateDAO {
	
	public static final String STATE_NUM = "snum";
	
	public void save(Orderstate transientInstance) {		
		Session session = getSession();
		try {
			session.beginTransaction().begin();
			session.saveOrUpdate(transientInstance);
			session.getTransaction().commit();
		} catch (RuntimeException re) {	
			session.getTransaction().rollback();
			throw re;
		} finally{
			closeSession();
		}
	}

	public void delete(Orderstate persistentInstance) {
		Session session = getSession();
		try {
			session.beginTransaction().begin();
			getSession().delete(persistentInstance);
			session.getTransaction().commit();			
		} catch (RuntimeException re){	
			session.getTransaction().rollback();
			throw re;
		} finally{
			closeSession();
		}
	}

	public Orderstate findById(Integer id) {		
		Session session = getSession();
		try {
			Orderstate instance = (Orderstate) session.get(
					"tarena.entity.Orderstate", id);			
			return instance;
		} catch (RuntimeException re) {
			return null;
		}finally{
			closeSession();
		}
	}
	
	public Orderstate findByOrdernum(Integer ordernum){
		Session session = getSession();
		try {
			Orderstate instance = (Orderstate) session
								  .createQuery("from Orderstate os where os."+STATE_NUM+"=? ")
								  .setParameter(0, ordernum)
								  .uniqueResult();
			return instance;
		} catch (RuntimeException re) {
			return null;
		}finally{
			closeSession();
		}
	}
}

⌨️ 快捷键说明

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