📄 jobutil.java
字号:
/*
* JobUtil.java
*
* Created on 2006年5月10日, 上午11:34
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package model.hr.hibernate;
import dbservice.hibernate.HibernateService;
import java.util.*;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.Transaction;
/**
*
* @author Administrator
*/
public class JobUtil {
public static boolean insert(Job job) {
Transaction transaction = null;
Session session = null;
boolean b = false;
try {
session = HibernateService.getSession();
transaction = session.beginTransaction();
session.save(job);
transaction.commit();
b = true;
}
catch (HibernateException he) {
he.printStackTrace();
HibernateService.rollbackTransaction(transaction);
b = false;
}
catch (Exception e) {
e.printStackTrace();
b = false;
}
finally {
HibernateService.closeSession(session);
return b;
}
}
public static List findAll() {
List list = null;
list = HibernateService.execQuery("from Job");
return list;
}
public static boolean addEmployees(String id, Employee employee) {
Transaction transaction = null;
Session session = null;
boolean b = false;
try {
session = HibernateService.getSession();
transaction = session.beginTransaction();
Job job = new Job();
session.load(job, Byte.valueOf(id));
employee.setJob(job);
session.update(job);
transaction.commit();
b = true;
}
catch (HibernateException he) {
he.printStackTrace();
HibernateService.rollbackTransaction(transaction);
b = false;
}
catch (Exception e) {
e.printStackTrace();
b = false;
}
finally {
HibernateService.closeSession(session);
return b;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -