Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
HibernateUtil.java
Package: (J2EE)oa.rar [view]
Upload User: lm2018
Upload Date: 2015-12-12
Package Size: 30449k
Code Size: 1k
Category:
Jsp/Servlet
Development Platform:
Java
- package com.oa.module.pub.ectomere;
- import java.io.Serializable;
- import org.hibernate.Session;
- import org.hibernate.SessionFactory;
- import org.hibernate.Transaction;
- public class HibernateUtil {
- private SessionFactory sf;
- Session session = null;
- Transaction tx = null;
- public boolean save(Object object){
- try {
- session = sf.openSession();
- tx = session.beginTransaction();
- session.save(object);
- tx.commit();
- session.flush();
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- tx.rollback();
- }finally{
- session.close();
- sf.close();
- }
- return false;
- }
- public Object get(Class poclass,Serializable ino){
- Object object = null;
- Session session = null;
- try {
- session = sf.openSession();
- object =session.get(poclass,ino);
- session.flush();
- } catch (Exception e) {
- e.printStackTrace();
- }finally{
- session.close();
- sf.close();
- }
- return object;
- }
- public boolean update(Object object){
- Session session = null;
- Transaction tx = null;
- try {
- session = sf.openSession();
- tx = session.beginTransaction();
- session.update(object);
- tx.commit();
- session.flush();
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- tx.rollback();
- }finally{
- session.close();
- sf.close();
- }
- return false;
- }
- public SessionFactory getSf() {
- return sf;
- }
- public void setSf(SessionFactory sf) {
- this.sf = sf;
- }
- }