?? storeoututil.java
字號:
/*
* StoreoutUtil.java
*
* Created on 2006年5月21日, 下午2:33
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package model.store.hibernate;
import dbservice.hibernate.HibernateService;
import java.util.List;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.Transaction;
/**
*
* @author Administrator
*/
public class StoreoutUtil {
public static boolean insert(String clientId, String productId, String roomId, Storeout storeout) {
Transaction transaction = null;
Session session = null;
boolean b = false;
try {
session = HibernateService.getSession();
transaction = session.beginTransaction();
ClientUtil.addStoreouts(clientId, storeout);
ProductUtil.addStoreouts(productId, storeout);
StoreroomUtil.addStoreouts(roomId, storeout);
session.save(storeout);
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;
Transaction transaction = null;
Session session = null;
try {
session = HibernateService.getSession();
transaction = session.beginTransaction();
list = HibernateService.execQuery("from Storeout");
transaction.commit();
HibernateService.closeSession(session);
}
catch (HibernateException he) {
he.printStackTrace();
HibernateService.rollbackTransaction(transaction);
list = null;
}
catch (Exception e) {
e.printStackTrace();
list = null;
}
finally {
HibernateService.closeSession(session);
return list;
}
}
public static Storeout find(String id) {
Storeout storeout = null;
Transaction transaction = null;
Session session = null;
try {
session = HibernateService.getSession();
transaction = session.beginTransaction();
storeout = new Storeout();
session.load(storeout, Integer.valueOf(id));
transaction.commit();
}
catch (HibernateException he) {
he.printStackTrace();
HibernateService.rollbackTransaction(transaction);
storeout = null;
}
catch (Exception e) {
e.printStackTrace();
storeout = null;
}
finally {
HibernateService.closeSession(session);
return storeout;
}
}
public static boolean update(String id, String clientId, String productId, String storeroomId, Storeout s) {
Transaction transaction = null;
Session session = null;
boolean b = false;
try {
session = HibernateService.getSession();
transaction = session.beginTransaction();
Storeout storeout = new Storeout();
session.load(storeout, Integer.valueOf(id));
storeout.setName(s.getName());
storeout.setOuttime(s.getOuttime());
storeout.setRemarks(s.getRemarks());
ClientUtil.addStoreouts(clientId, storeout);
ProductUtil.addStoreouts(productId, storeout);
StoreroomUtil.addStoreouts(storeroomId, storeout);
session.update(storeout);
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 + -