List of usage examples for org.hibernate Session disconnect
Connection disconnect();
From source file:Agente.altaAgente.java
private List<Object[]> executeHQLQuery(String hql) { Session session = HibernateUtil.getSessionFactory().openSession(); try {/* ww w . ja va2 s. c o m*/ session.beginTransaction(); Query q = session.createQuery(hql); List resultList = q.list(); session.getTransaction().commit(); session.disconnect(); return resultList; } catch (HibernateException he) { he.printStackTrace(); List lista = null; return lista; } }
From source file:Agente.buscaAgentes.java
private List<Object[]> executeHQLQuery(String hql) { try {//from w ww . ja v a 2 s . co m Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); Query q = session.createQuery(hql); List resultList = q.list(); session.getTransaction().commit(); session.disconnect(); return resultList; } catch (HibernateException he) { he.printStackTrace(); List lista = null;//new List(5); return lista; } }
From source file:ar.edu.utn.sigmaproject.webflow.Hibernate4FlowExecutionListener.java
License:Apache License
public void paused(RequestContext context) { if (isPersistenceContext(context.getActiveFlow())) { Session session = getHibernateSession(context.getFlowExecutionContext().getActiveSession()); unbind(session);/* ww w. j av a 2 s . c om*/ session.disconnect(); } }
From source file:Clientes.altaCliente.java
private List<Object[]> executeHQLQuery(String hql) { try {/*from w w w . jav a 2s. c om*/ Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); Query q = session.createQuery(hql); List resultList = q.list(); session.getTransaction().commit(); session.disconnect(); return resultList; } catch (HibernateException he) { he.printStackTrace(); List lista = null; return lista; } }
From source file:Clientes.editaCliente.java
private List<Object[]> executeHQLQuery(String hql) { Session session = HibernateUtil.getSessionFactory().openSession(); try {/*from w w w.j a va 2 s . c om*/ session.beginTransaction(); Query q = session.createQuery(hql); List resultList = q.list(); session.getTransaction().commit(); session.disconnect(); return resultList; } catch (HibernateException he) { he.printStackTrace(); List lista = null; return lista; } finally { if (session.isOpen()) session.close(); } }
From source file:club.jmint.mifty.dao.Dao.java
License:Apache License
public static void closeSession(Session session) { session.disconnect(); session.close(); }
From source file:com.byteslounge.spring.tx.MyOwnTxManager.java
License:Apache License
@Override protected void doCleanupAfterCompletion(Object transaction) { HibernateTransactionObject txObject = (HibernateTransactionObject) transaction; // Remove the session holder from the thread. if (txObject.isNewSessionHolder()) { TransactionSynchronizationManager.unbindResource(getSessionFactory()); }//from ww w . j av a 2 s.c o m // Remove the JDBC connection holder from the thread, if exposed. if (getDataSource() != null) { TransactionSynchronizationManager.unbindResource(getDataSource()); } Session session = txObject.getSessionHolder().getSession(); if (this.prepareConnection && session.isConnected() && isSameConnectionForEntireSession(session)) { // We're running with connection release mode "on_close": We're able to reset // the isolation level and/or read-only flag of the JDBC Connection here. // Else, we need to rely on the connection pool to perform proper cleanup. try { Connection con = ((SessionImplementor) session).connection(); DataSourceUtils.resetConnectionAfterTransaction(con, txObject.getPreviousIsolationLevel()); } catch (HibernateException ex) { logger.debug("Could not access JDBC Connection of Hibernate Session", ex); } } if (txObject.isNewSession()) { if (logger.isDebugEnabled()) { logger.debug("Closing Hibernate Session [" + session + "] after transaction"); } SessionFactoryUtils.closeSession(session); } else { if (logger.isDebugEnabled()) { logger.debug("Not closing pre-bound Hibernate Session [" + session + "] after transaction"); } if (txObject.getSessionHolder().getPreviousFlushMode() != null) { session.setFlushMode(txObject.getSessionHolder().getPreviousFlushMode()); } if (!this.hibernateManagedSession) { session.disconnect(); } } txObject.getSessionHolder().clear(); }
From source file:com.cosylab.cdb.jdal.hibernate.HibernateUtil.java
License:Open Source License
/** * Disconnect and return Session from current Thread. * * @return Session the disconnected Session *//*from w ww.j a v a 2s . c o m*/ public Session disconnectSession() throws HibernateUtilException { Session session = getSession(); try { threadSession.set(null); if (session.isConnected() && session.isOpen()) session.disconnect(); } catch (HibernateException ex) { throw new HibernateUtilException(ex); } return session; }
From source file:com.viettel.ttbankplus.servicegw.hibernate.utils.HibernateSessionFactory.java
License:Open Source License
/** * Disconnect and return Session from current Thread. * * @return Session the disconnected Session *//*from ww w .j a va 2s . c o m*/ public static Session disconnectSession() { Session session = getSession(); try { threadSession.set(null); if (session.isConnected() && session.isOpen()) { session.disconnect(); } } catch (HibernateException ex) { log.error("%%%% disconnectSession %%%% ==" + ex.getMessage()); System.err.println("%%%% Error disconnectSession %%%%"); } return session; }
From source file:Compania.NuevaCompania.java
private List<Object[]> executeHQLQuery(String hql) { try {/*from www .ja v a 2s . c om*/ Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction().begin(); Query q = session.createQuery(hql); List resultList = q.list(); session.getTransaction().commit(); session.disconnect(); return resultList; } catch (HibernateException he) { he.printStackTrace(); List lista = null;//new List(5); return lista; } }