📄 maritalutil.java
字号:
/*
* MaritalUtil.java
*
* Created on 2006年6月10日, 下午5:56
*
* 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 MaritalUtil {
public static boolean insert(Marital marital) {
Transaction transaction = null;
Session session = null;
boolean b = false;
try {
session = HibernateService.getSession();
transaction = session.beginTransaction();
session.save(marital);
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 Marital");
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();
Marital marital = new Marital();
session.load(marital, Byte.valueOf(id));
employee.setMarital(marital);
session.update(marital);
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 + -