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

📄 empdaoimpl.java

📁 这是大唐电信的一个管理系统
💻 JAVA
字号:
package com.tatang.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.tatang.dao.IEmpDao;
import com.tatang.po.TEmployee;
import com.tatang.util.HibernateSessionFactory;

public class EmpDaoImpl implements IEmpDao{

	public List<TEmployee> empList(Integer id) {
		Session session = null;
		Transaction tx = null;
		Query q = null;
		String sql="from TEmployee";
		try{
			session = HibernateSessionFactory.getSession();
			tx = session.beginTransaction();
			q = session.createQuery(sql);
			q.setInteger(0,id);
			List<TEmployee> list = new ArrayList();
			list = q.list();
			tx.commit();
			return list;
		}catch(HibernateException e){
			tx.rollback();
			e.printStackTrace();
			return null;
		}finally{
			HibernateSessionFactory.closeSession();
		}
	}

	public List<TEmployee> empList() {
		Session session = null;
		Transaction tx = null;
		Query q = null;
		String sql="from TEmployee";
		try{
			session = HibernateSessionFactory.getSession();
			tx = session.beginTransaction();
			q = session.createQuery(sql);
			List<TEmployee> list = new ArrayList();
			list = q.list();
			tx.commit();
			return list;
		}catch(HibernateException e){
			tx.rollback();
			e.printStackTrace();
			return null;
		}finally{
			HibernateSessionFactory.closeSession();
		}
	}
   
}

⌨️ 快捷键说明

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