Thanks for your response - we are using pretty default HibernateUtil methods to set up the connections. I just call the static methods to get session and all that. If calling configuration.configure(document) is the only way I can be calling and recalling these server settings it definitely does narrow things down.
Thank you,
s
Code:
public class HibernateUtil {
private static final Log LOG = LogFactory.getLog(HibernateUtil.class);
private static final SessionFactory sessionFactory;
private static final ThreadLocal threadSession = new ThreadLocal();
private static final ThreadLocal threadTransaction = new ThreadLocal();
static{
try{
DocumentBuilderFactory fct = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = fct.newDocumentBuilder();
Document doc = docBuilder.parse("hibernate.cfg.xml");
Configuration cfg = new Configuration();
cfg.configure(doc);
sessionFactory = cfg.buildSessionFactory();
}catch (Throwable ex){
LOG.error(ex);
throw new ExceptionInInitializerError(ex);
}
}
public static Session getSession()throws XOpsException{
Session s = (Session)threadSession.get();
try{
if(s == null){
s = sessionFactory.openSession();
threadSession.set(s);
}
}catch(HibernateException ex){
LOG.error(ex);
throw new XOpsException(ex);
}
return s;
}
public static void closeSession()throws XOpsException{
try{
Session s = (Session)threadSession.get();
threadSession.set(null);
if(s != null && s.isOpen()){
s.close();
}
}catch(HibernateException ex){
LOG.error(ex);
throw new XOpsException(ex);
}
}
public static void beginTransaction()throws XOpsException{
Transaction tx = (Transaction) threadTransaction.get();
try{
if(tx == null){
tx = getSession().beginTransaction();
threadTransaction.set(tx);
}
}catch(HibernateException ex){
LOG.error(ex);
throw new XOpsException(ex);
}
}
public static void commitTransaction()throws XOpsException{
Transaction tx = (Transaction)threadTransaction.get();
try{
if(tx != null && !tx.wasCommitted()&& !tx.wasRolledBack()){
tx.commit();
}
threadTransaction.set(null);
}catch(HibernateException ex){
rollbackTransaction();
LOG.error(ex);
throw new XOpsException(ex);
}
}
public static void rollbackTransaction() throws XOpsException{
Transaction tx = (Transaction)threadTransaction.get();
try{
threadTransaction.set(null);
if(tx != null && !tx.wasCommitted() && !tx.wasRolledBack()){
tx.rollback();
}
}catch(HibernateException ex){
LOG.error(ex);
throw new XOpsException(ex);
}finally{
closeSession();
}
}
}