src/com/jiudai/dao/EmployeeDAO.java
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
package com.jiudai.dao;
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.jiudai.Utils.HibernateUtil;
import com.jiudai.domain.Employee;
public class EmployeeDAO {
public ArrayList<Employee> QueryAllEmployee() {
Session s = null;
try {
s = HibernateUtil.getSession();
String hql = "From Employee";
Query q = s.createQuery(hql);
List employeeList = q.list();
return (ArrayList<Employee>) employeeList;
} finally {
HibernateUtil.closeSession();
}
}
public void AddEmployee(Employee employee) {
Session s = null;
Transaction tx = null;
try {
s = HibernateUtil.getSession();
tx = s.beginTransaction();
s.save(employee);
tx.commit();
} catch (HibernateException e) {
if(tx != null)
tx.rollback();
throw e;
} finally {
HibernateUtil.closeSession();
}
}
public Employee GetEmployee(int id) {
Session s = null;
try {
s = HibernateUtil.getSession();
Employee employee = (Employee)s.get(Employee.class, id);
return employee;
} finally {
HibernateUtil.closeSession();
}
}
public void ModifyEmployee(Employee employee) {
Session s = null;
Transaction tx = null;
后面还有 15 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
