Changeset 7368


Ignore:
Timestamp:
May 17, 2017, 10:31:38 AM (5 years ago)
Author:
Nicklas Nordborg
Message:

References #2084: Upgrade to Hibernate 5.2

Hibernate is throwing different exception now which caused some of our error handling code to failed (eg. detecting duplicates in the database). Trying to get back as much of the old behaviour as possible. This fixes a few failed tests:

TestReporter FAILED
TestReporterList FAILED
TestArrayDesign FAILED
TestRawBioAssay FAILED
TestSpotImages FAILED
TestDbControl FAILED
TestItemImporter FAILED
TestReporterFlatFileImporter FAILED
TestReporterMapFlatFileImporter FAILED
TestPlateFlatFileImporter FAILED
TestRawDataFlatFileImporter FAILED
TestPrintMapFlatFileImporter FAILED
TestGalExporter FAILED
TestDirty FAILED
TestIlluminaImporter FAILED
TestGtfImporters FAILED
TestBasicAnalysis FAILED
TestReporterCloneTemplate FAILED
TestIntensityCalculatorPlugin FAILED
TestLowessNormalization FAILED
TestMedianRatioNormalization FAILED
TestBaseFileExporterImporter FAILED
TestBfsExporterImporter FAILED
TestBase1PluginExecuter FAILED
TestExternalProgramExecutor FAILED
++25 tests failed!
++82 tests succeeded!
Location:
branches/hibernate-5.2/src/core/net/sf/basedb/core
Files:
2 edited

Legend:

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

    r7366 r7368  
    6565import java.util.jar.JarEntry;
    6666import java.util.jar.JarFile;
     67
     68import javax.persistence.PersistenceException;
    6769
    6870import java.sql.Connection;
     
    13261328      tx.commit();
    13271329    }
    1328     catch (ConstraintViolationException ex)
    1329     {
    1330       // This is the best we can do... I think...
    1331       throw new DatabaseException(ex.getSQLException());
    1332     }
    1333     catch (StaleStateException ex)
    1334     {
    1335       throw new ItemModifiedException(ex);
    1336     }
    1337     catch(HibernateException ex)
    1338     {
    1339       throw new BaseException(ex);
     1330    catch (PersistenceException ex)
     1331    {
     1332      Throwable cause = ex.getCause();
     1333      if (cause instanceof HibernateException) ex = (HibernateException)cause;
     1334     
     1335      if (ex instanceof ConstraintViolationException)
     1336      {
     1337        // This is the best we can do... I think...
     1338        throw new DatabaseException(((ConstraintViolationException)ex).getSQLException());
     1339      }
     1340      else if (ex instanceof StaleStateException)
     1341      {
     1342        throw new ItemModifiedException((StaleStateException)ex);
     1343      }
     1344      else
     1345      {
     1346        throw new BaseException(ex);
     1347      }
    13401348    }
    13411349  }
     
    14021410      session.flush();
    14031411    }
    1404     catch (ConstraintViolationException ex)
    1405     {
    1406       // This is the best we can do... I think...
    1407       throw new DatabaseException(ex.getSQLException());
    1408     }
    1409     catch (StaleStateException ex)
    1410     {
    1411       throw new ItemModifiedException(ex);
    1412     }
    1413     catch (HibernateException ex)
    1414     {
    1415       throw new BaseException(ex);
     1412    catch (PersistenceException ex)
     1413    {
     1414      Throwable cause = ex.getCause();
     1415      if (cause instanceof HibernateException) ex = (HibernateException)cause;
     1416     
     1417      if (ex instanceof ConstraintViolationException)
     1418      {
     1419        // This is the best we can do... I think...
     1420        throw new DatabaseException(((ConstraintViolationException)ex).getSQLException());
     1421      }
     1422      else if (ex instanceof StaleStateException)
     1423      {
     1424        throw new ItemModifiedException((StaleStateException)ex);
     1425      }
     1426      else
     1427      {
     1428        throw new BaseException(ex);
     1429      }
    14161430    }
    14171431  }
     
    14481462      session.save(data);
    14491463    }
    1450     catch (ConstraintViolationException ex)
    1451     {
    1452       // This is the best we can do... I think...
    1453       throw new DatabaseException(ex.getSQLException());
    1454     }
    1455     catch(HibernateException ex)
    1456     {
    1457       throw new BaseException(ex);
     1464    catch (PersistenceException ex)
     1465    {
     1466      Throwable cause = ex.getCause();
     1467      if (cause instanceof HibernateException) ex = (HibernateException)cause;
     1468     
     1469      if (ex instanceof ConstraintViolationException)
     1470      {
     1471        // This is the best we can do... I think...
     1472        throw new DatabaseException(((ConstraintViolationException)ex).getSQLException());
     1473      }
     1474      else
     1475      {
     1476        throw new BaseException(ex);
     1477      }
    14581478    }
    14591479  }
     
    14711491      session.insert(data);
    14721492    }
    1473     catch (ConstraintViolationException ex)
    1474     {
    1475       // This is the best we can do... I think...
    1476       throw new DatabaseException(ex.getSQLException());
    1477     }
    1478     catch(HibernateException ex)
    1479     {
    1480       throw new BaseException(ex);
     1493    catch (PersistenceException ex)
     1494    {
     1495      Throwable cause = ex.getCause();
     1496      if (cause instanceof HibernateException) ex = (HibernateException)cause;
     1497     
     1498      if (ex instanceof ConstraintViolationException)
     1499      {
     1500        // This is the best we can do... I think...
     1501        throw new DatabaseException(((ConstraintViolationException)ex).getSQLException());
     1502      }
     1503      else
     1504      {
     1505        throw new BaseException(ex);
     1506      }
    14811507    }
    14821508  }
  • branches/hibernate-5.2/src/core/net/sf/basedb/core/hibernate/SchemaGenerator.java

    r7367 r7368  
    131131      if (mode == Mode.UPDATE)
    132132      {
    133         log.info("Fetching database metadata");
    134         /*
    135         ServiceRegistry serviceRegistry = ((MetadataImplementor)metadata).getMetadataBuildingOptions().getServiceRegistry();
    136         JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
    137         JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment();
    138         JdbcConnectionAccess jdbcConnectionAccess = jdbcServices.getBootstrapJdbcConnectionAccess();
    139         Namespace ns = metadata.getDatabase().getDefaultNamespace();
    140         DatabaseInformation existingDatabase = new DatabaseInformationImpl(serviceRegistry, jdbcEnvironment, jdbcConnectionAccess, ns.getPhysicalName().getCatalog(), ns.getPhysicalName().getSchema());
    141         */
    142        
    143133        log.info("Generating schema update script");
    144134        SchemaMigrator schemaMigrator = new IndividuallySchemaMigratorImpl(tool, null);
Note: See TracChangeset for help on using the changeset viewer.