code: protected boolean isSameConnectionForEntireSession(Session session) {
      // The best we can do is to assume we're safe.
      if (!(session instanceof TransactionContext)) return true;
      ConnectionReleaseMode releaseMode = ((TransactionContext) session).getConnectionReleaseMode();
      return ConnectionReleaseMode.ON_CLOSE.equals(releaseMode);
    }
docs: Return whether the given Hibernate Session will always hold the same
  JDBC Connection. This is used to check whether the transaction manager
  can safely prepare and clean up the JDBC Connection used for a transaction.
  <p>
  Default implementation checks the Session's connection release mode to be "on_close".
  Unfortunately, this requires casting to SessionImpl, as of Hibernate 3.1. If that cast doesn't
  work, we'll simply assume we're safe and return <code>true</code>.
  
  @param session the Hibernate Session to check
  @see org.hibernate.impl.SessionImpl#getConnectionReleaseMode()
  @see org.hibernate.ConnectionReleaseMode#ON_CLOSE