Changeset 7370


Ignore:
Timestamp:
May 17, 2017, 11:34:07 AM (5 years ago)
Author:
Nicklas Nordborg
Message:

References #2084: Upgrade to Hibernate 5.2

The disconnect()/reconnect() methods are now no-op and deprecated. Removed the test case. All tests are now working. Remains to fix the file upload code.

Location:
branches/hibernate-5.2/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/DbControl.java

    r7262 r7370  
    141141 
    142142  /**
    143     If Hibernate is connected to the database or not.
    144   */
    145   private boolean isConnected;
    146 
    147   /**
    148143    If the current transaction has been rolled back or not.
    149144  */
     
    181176    uniqueRandoms = new HashSet<String>();
    182177    isClosed = false;
    183     isConnected = true;
    184178    calledFrom = new Throwable("Please check the code to make sure that DbControl.close() " +
    185179      "is always called. Stacktrace of code that created this DbControl:");
     
    273267      @throws ConnectionClosedException If connection to database has been closed.
    274268    @throws BaseException If there is another error
    275   */
     269    @deprecated In 3.11. Applications should use separate DbControl instead.
     270  */
     271  @Deprecated
    276272  public void disconnect()
    277273    throws ConnectionClosedException, BaseException
    278274  {
    279     if (isClosed()) throw new ConnectionClosedException();
    280275    sc.updateLastAccess();
    281     HibernateUtil.rollback(hTransaction);
    282     hSession.disconnect();
    283     isConnected = false;
    284276  }
    285277 
     
    288280    @throws ConnectionClosedException If connection to database has been closed.
    289281    @throws BaseException If there is another error.
    290   */
     282    @deprecated In 3.11. Applications should use separate DbControl instead.
     283  */
     284  @Deprecated
    291285  public void reconnect()
    292286    throws ConnectionClosedException, BaseException
    293287  {
    294     if (isClosed()) throw new ConnectionClosedException();
    295288    sc.updateLastAccess();
    296     hTransaction = HibernateUtil.newTransaction(hSession);
    297     isConnected = true;
    298289  }
    299290 
    300291  /**
    301292    Checks if there is an active connection to the database or not.
    302   */
     293    @deprecated In 3.11. Applications should use separate DbControl instead.
     294  */
     295  @Deprecated
    303296  public boolean isConnected()
    304297  {
    305     return isConnected;
     298    return isClosed;
    306299  }
    307300 
     
    358351    try
    359352    {
    360       if (isConnected) HibernateUtil.rollback(hTransaction);
     353      HibernateUtil.rollback(hTransaction);
    361354      HibernateUtil.close(hSession);
    362355      if (hStatelessSession != null) HibernateUtil.close(hStatelessSession);
     
    411404    batchers = null;
    412405    isClosed = true;
    413     isConnected = false;
    414406  }
    415407 
  • branches/hibernate-5.2/src/test/TestDbControl.java

    r5058 r7370  
    4343    int roleId = TestRole.test_create(true);
    4444    test_detach(roleId);
    45     test_disconnect(roleId);
    4645    TestRole.test_delete(roleId);
    4746
     
    150149  }
    151150
    152   static void test_disconnect(int roleId)
    153   {
    154     if (roleId == 0) return;
    155     DbControl dc = null;
    156     try
    157     {
    158       dc = TestUtil.getDbControl();
    159       Role r = Role.getById(dc, roleId);
    160       TestRole.write_item(0, r);
    161      
    162       dc.disconnect();
    163       if (dc.isConnected())
    164       {
    165         throw new BaseException("DbControl is still connected");
    166       }
    167       r.setName("Disconnected role");
    168       dc.reconnect();
    169       dc.commit();
    170      
    171       dc = TestUtil.getDbControl();
    172       r = Role.getById(dc, roleId);
    173       TestRole.write_item(1, r);
    174       if (!"Disconnected role".equals(r.getName())) throw new BaseException("Role.getName() != Disconnected role");
    175       write("--Test disconnect OK");
    176     }
    177     catch (Throwable ex)
    178     {
    179       write("--Test disconnect FAILED");
    180       ex.printStackTrace();
    181       ok = false;
    182     }
    183     finally
    184     {
    185       if (dc != null) dc.close();
    186     }
    187   }
    188 
    189151  static void write(String message)
    190152  {
Note: See TracChangeset for help on using the changeset viewer.