Package org.hibernate

Examples of org.hibernate.Session.connection()


  @Override
  public ConnectionHandle getJdbcConnection(EntityManager entityManager, boolean readOnly)
      throws PersistenceException, SQLException {

    Session session = getSession(entityManager);
    Connection con = session.connection();
    return (con != null ? new SimpleConnectionHandle(con) : null);
  }

  public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
    if (ex instanceof HibernateException) {
View Full Code Here


        Connection con = null;
        try {
            List list = new ArrayList();
           
            ses = ((HibernatePersistenceStrategy)strategy).getSession();
            con = ses.connection();
           
            final PreparedStatement stmt;
           
            Dialect currentDialect = ((SessionFactoryImplementor)ses.getSessionFactory()).getDialect();
           
View Full Code Here

  protected boolean readCommittedIsolationMaintained(String scenario) {
    int isolation = java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;
    Session testSession = null;
    try {
      testSession = openSession();
      isolation = testSession.connection().getTransactionIsolation();
    }
    catch( Throwable ignore ) {
    }
    finally {
      if ( testSession != null ) {
View Full Code Here

  }
 
  public static void shutdown() {
    try {
      Session session = sessionFactory.openSession();
      Statement stmt = session.connection().createStatement();
      stmt.execute("SHUTDOWN");
      session.close();
      sessionFactory.close();
    } catch (Exception e) {
      // TODO Auto-generated catch block
View Full Code Here

    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 = session.connection();
        DataSourceUtils.resetConnectionAfterTransaction(con, txObject.getPreviousIsolationLevel());
      }
      catch (HibernateException ex) {
        logger.debug("Could not access JDBC Connection of Hibernate Session", ex);
      }
View Full Code Here

    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 = session.connection();
        DataSourceUtils.resetConnectionAfterTransaction(con, txObject.getPreviousIsolationLevel());
      }
      catch (HibernateException ex) {
        logger.debug("Could not access JDBC Connection of Hibernate Session", ex);
      }
View Full Code Here

  @Override
  public ConnectionHandle getJdbcConnection(EntityManager entityManager, boolean readOnly)
      throws PersistenceException, SQLException {

    Session session = getSession(entityManager);
    Connection con = session.connection();
    return (con != null ? new SimpleConnectionHandle(con) : null);
  }

  protected Session getSession(EntityManager em) {
    return ((HibernateEntityManager) em).getSession();
View Full Code Here

    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 = session.connection();
        DataSourceUtils.resetConnectionAfterTransaction(con, txObject.getPreviousIsolationLevel());
      }
      catch (HibernateException ex) {
        logger.debug("Could not access JDBC Connection of Hibernate Session", ex);
      }
View Full Code Here

  @Override
  public ConnectionHandle getJdbcConnection(EntityManager entityManager, boolean readOnly)
      throws PersistenceException, SQLException {

    Session session = getSession(entityManager);
    Connection con = session.connection();
    return (con != null ? new SimpleConnectionHandle(con) : null);
  }

  public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
    if (ex instanceof HibernateException) {
View Full Code Here

    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 = session.connection();
        DataSourceUtils.resetConnectionAfterTransaction(con, txObject.getPreviousIsolationLevel());
      }
      catch (HibernateException ex) {
        logger.debug("Could not access JDBC Connection of Hibernate Session", ex);
      }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.