谁帮我逐句解释一下这个JAVA的代码?谢谢了

来源:百度知道 编辑:UC知道 时间:2024/05/22 15:06:36
package org.hibernate.service;

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

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

import com.webwork.models.TEmp;
import com.webwork.models.TProject;

public class TEmpServiceImpl implements TEmpService {

Session session = null;

Transaction tran = null;

public TEmpServiceImpl() {

Configuration config = new Configuration().configure();
SessionFactory sessionFactory = config.buildSessionFactory();
session = sessionFactory.openSession();
}

public List getListByEid(Long eId) throws Exception{

List list = new ArrayList();

String hql = "FROM TEmp temp WHERE temp.EId = '" + eId + "' ";
Q

public class TEmpServiceImpl implements TEmpService {

Session session = null;

Transaction tran = null;

public TEmpServiceImpl() {

Configuration config = new Configuration().configure(); //hibernate配置类实例,包含hibernate主配置文件及数据库连接信息等
SessionFactory sessionFactory = config.buildSessionFactory(); //创建hiberante的会话工厂
session = sessionFactory.openSession(); 打开会话
}

public List getListByEid(Long eId) throws Exception{

List list = new ArrayList();

String hql = "FROM TEmp temp WHERE temp.EId = '" + eId + "' "; hql对象查询语句
Query query = session.createQuery(hql); 根据hql创建hibernate Query对象

list = query.list(); 返回查询结果集,list内部为n个TEmpl对象实例
return list;

}

public void delete(TEmp tEmp) throws Exception {
// TODO Auto-generated method stub
if (tEmp != null) {
tran = session.beginTransaction(); 开启事务
session.delete(tEm