private void errorIfReadOnlySettingNotAvailable() { if ( session == null ) { throw new TransientObjectException( "Proxy is detached (i.e, session is null). The read-only/modifiable setting is only accessible when the proxy is associated with an open session." ); } if ( session.isClosed() ) { throw new SessionException( "Session is closed. The read-only/modifiable setting is only accessible when the proxy is associated with an open session." ); } }
@Override public Connection close() throws HibernateException { LOG.trace( "Closing session" ); if ( isClosed() ) { throw new SessionException( "Session was already closed" ); } if ( factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().closeSession(); } getEventListenerManager().end(); try { if ( !isTransactionCoordinatorShared ) { return transactionCoordinator.close(); } else { if ( getActionQueue().hasBeforeTransactionActions() || getActionQueue().hasAfterTransactionActions() ) { LOG.warn( "On close, shared Session had before / after transaction actions that have not yet been processed" ); } else { transactionCoordinator.removeObserver( transactionObserver ); } return null; } } finally { setClosed(); cleanup(); } }
@Override public void managedClose() { if ( isClosed() ) { throw new SessionException( "Session was already closed!" ); } transactionCoordinator.close(); setClosed(); }
@ExceptionHandler({ SessionLimitExceededException.class, HttpSessionRequiredException.class, SessionException.class, SessionAuthenticationException.class, }) public String handleSessionRequired(Exception e, RedirectAttributes attr){ attr.addFlashAttribute("error","Your session has been expired. Please log in again."); return "redirect:/error"; }
@ExceptionHandler({ HttpSessionRequiredException.class, SessionException.class, SessionAuthenticationException.class, }) public String handleSessionRequired(Exception e, RedirectAttributes attr){ e.printStackTrace(); attr.addFlashAttribute("error","Your session has been expired. Please log in again."); return "redirect:/oups"; }
public Connection connection() throws HibernateException { if ( owner.isClosed() ) { throw new SessionException( "Session is closed" ); } return connectionManager.getConnection(); }
public Connection close() throws HibernateException { log.trace( "closing session" ); if ( isClosed() ) { throw new SessionException( "Session was already closed" ); } if ( factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().closeSession(); } try { try { if ( childSessionsByEntityMode != null ) { Iterator childSessions = childSessionsByEntityMode.values().iterator(); while ( childSessions.hasNext() ) { final SessionImpl child = ( SessionImpl ) childSessions.next(); child.close(); } } } catch( Throwable t ) { // just ignore } if ( rootSession == null ) { return jdbcContext.getConnectionManager().close(); } else { return null; } } finally { setClosed(); cleanup(); } }
public void managedClose() { if ( isClosed() ) { throw new SessionException( "Session was already closed!" ); } jdbcContext.getConnectionManager().close(); setClosed(); }
public Session getSession() { Session session; try { session = sessionFactory.getCurrentSession(); } catch (SessionException se) { session = sessionFactory.openSession(); } return session; }
protected void errorIfClosed() { if ( isClosed() ) { throw new SessionException( "Session is closed!" ); } }
@Override public Object immediateLoad(String entityName, Serializable id) throws HibernateException { throw new SessionException("proxies cannot be fetched by a stateless session"); }
@Override public void initializeCollection( PersistentCollection collection, boolean writing) throws HibernateException { throw new SessionException("collections cannot be fetched by a stateless session"); }
protected void errorIfClosed() { if ( closed ) { throw new SessionException( "Session is closed!" ); } }
public Object immediateLoad(String entityName, Serializable id) throws HibernateException { throw new SessionException("proxies cannot be fetched by a stateless session"); }
public void initializeCollection( PersistentCollection collection, boolean writing) throws HibernateException { throw new SessionException("collections cannot be fetched by a stateless session"); }