[code]package com.t48.hr.util;
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.t48.hr.util.HBSessionFactory;
public abstract class TransManager {
public Session sess;
public abstract void process() throws Exception;
public void execute() throws Exception
{
Transaction trans=null;
try {
sess=HBSessionFactory.getCurrentSession();
trans=sess.beginTransaction();
process();
trans.commit();
} catch (Exception e) {
trans.rollback();
e.printStackTrace();
throw e;
// TODO: handle exception
}
finally{
HBSessionFactory.closeCurrentSession();
}
}
}[/code]
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.t48.hr.util.HBSessionFactory;
public abstract class TransManager {
public Session sess;
public abstract void process() throws Exception;
public void execute() throws Exception
{
Transaction trans=null;
try {
sess=HBSessionFactory.getCurrentSession();
trans=sess.beginTransaction();
process();
trans.commit();
} catch (Exception e) {
trans.rollback();
e.printStackTrace();
throw e;
// TODO: handle exception
}
finally{
HBSessionFactory.closeCurrentSession();
}
}
}[/code]