Package org.hibernate

Examples of org.hibernate.Session.connection()


  @SuppressWarnings("deprecation")
  public String extractFactoryURL(SessionFactory factory) {
    Session session = null;
    try {
      session = factory.openSession();
      return session.connection().getMetaData().getURL();
    } catch (SQLException e) {
      throw new HiveRuntimeException(e);
    } finally {
      if(session != null)
        session.close();
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

  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

   * @throws SQLException in case the insert fails.
   */
  private TShirt createObjectWithSQL() throws SQLException {
    Session s = openSession();
    s.getTransaction().begin();
    Statement statement = s.connection().createStatement();
    statement.executeUpdate(
        "insert into TShirt_Master(id, logo, size_) values( 1, 'JBoss balls', 'large')"
    );
    statement.close();
    TShirt ts = ( TShirt ) s.get( TShirt.class, 1 );
View Full Code Here

    SQLExceptionConverter converter = getDialect().buildSQLExceptionConverter();

    Session session = openSession();
    session.beginTransaction();
    Connection connection = session.connection();

    // Attempt to insert some bad values into the T_MEMBERSHIP table that should
    // result in a constraint violation
    PreparedStatement ps = null;
    try {
View Full Code Here

  public void testBadGrammar() throws Exception {
    SQLExceptionConverter converter = getDialect().buildSQLExceptionConverter();

    Session session = openSession();
    session.beginTransaction();
    Connection connection = session.connection();

        // prepare/execute a query against a non-existent table
    PreparedStatement ps = null;
    try {
      ps = connection.prepareStatement("SELECT user_id, user_name FROM tbl_no_there");
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

  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

  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

    cmp.put( "a", new Integer(1) );
    cmp.put( "b", new Float(1.0) );
    map.put("cmp", cmp);
    s.save(map);
    s.flush();
    s.connection().commit();
    s.close();

    s = openSession().getSession(EntityMode.MAP);
    map = (Map) s.get( "TestMap", (Serializable) map.get("id") );
    assertTrue( map!=null && "foo".equals( map.get("name") ) );
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.