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

📄 planemodeldaofromhbn.java

📁 航空售票系统的代码
💻 JAVA
字号:
package com.tarena.abs.dao;

import java.util.*;
import java.io.*;
import org.hibernate.*;

import com.tarena.abs.model.PlaneModel;

public class PlaneModelDaoFromHbn implements PlaneModelDAO {
	
	public boolean addPlaneModel(PlaneModel plane) {
		Session s = null;
		Transaction t = null;
		boolean b = false;
		try {
			 s = HbnUtil.getSession();
			 t = s.beginTransaction();
			s.save(plane);
			t.commit();
			b=true;
		} catch (HibernateException e) {
			e.printStackTrace();
			t.rollback();
		} finally{
			if(s!=null)try{s.close();}catch(Exception e){e.printStackTrace();}
		}
		return b;
	}

	public Set getAllPlaneModel() {
		Session s = null;
		Transaction t = null;
		HashSet hs = new HashSet();
		try {
			 s = HbnUtil.getSession();
			 t = s.beginTransaction();
			 String hql="from PlaneModel";
			 List l = s.createQuery(hql)
			 						.list();
			 //System.out.println(l==null);
			 hs.addAll(l);
			 //System.out.println(hs+" "+hs.size());
			t.commit();
		} catch (HibernateException e) {
			e.printStackTrace();
			t.rollback();
		} finally{
			if(s!=null)try{s.close();}catch(Exception e){e.printStackTrace();}
			
		}
		return hs;
	}

	public boolean removePlaneModel(String model) {
		Session s = null;
		Transaction t = null;
		boolean b = false;
		try {
			 s = HbnUtil.getSession();
			 t = s.beginTransaction();
			 String hql="from PlaneModel";
			 PlaneModel pm = (PlaneModel)s.createQuery(hql)
			 						.uniqueResult();
			t.commit();
			b = true;
		} catch (HibernateException e) {
			e.printStackTrace();
			t.rollback();
		} finally{
			if(s!=null)try{s.close();}catch(Exception e){e.printStackTrace();}
		}
		return b;
	}

	

}

⌨️ 快捷键说明

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