Opened 8 years ago
Closed 7 years ago
#2084 closed enhancement (fixed)
Upgrade to Hibernate 5.2
Reported by: | Nicklas Nordborg | Owned by: | Nicklas Nordborg |
---|---|---|---|
Priority: | major | Milestone: | BASE 3.12 |
Component: | core | Version: | |
Keywords: | Cc: |
Description
Latest version is Hibernate 5.2.10 (we are currently running Hibernate 5.0.7).
As always, it is a bit complicated to update Hibernate. Simply replacing the old JAR file with the new version causes 131 errors and 1477 warnings. Most seems to be related to things that have been moved around due to merging the Hibernate API with the Java Persistence API (JPA) (see https://github.com/hibernate/hibernate-orm/wiki/Migration-Guide---5.2).
Hopefully, this change will not be as difficult as the last Hibernate update (#1979).
Change History (31)
comment:1 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 8 years ago
Summary: | Upgrade Hibernate → Upgrade to Hibernate 5.2 |
---|
comment:3 by , 8 years ago
comment:4 by , 8 years ago
comment:5 by , 8 years ago
comment:6 by , 8 years ago
comment:7 by , 8 years ago
comment:8 by , 8 years ago
(In [7367]) References #2084: Upgrade to Hibernate 5.2
Fixed compilation errors in DbIndexWork
and SchemaGenerator
. The code can now be compiled (1332 warnings) and the installation program runs without any problem.
Need to compare the generated database with one generated with the old Hibernate.
Some test program fails:
TestUser FAILED TestGlobalDefaultSetting FAILED TestClientDefaultSetting FAILED TestUserDefaultSetting FAILED TestUserClientSetting FAILED TestReporter FAILED TestReporterList FAILED TestArrayDesign FAILED TestRawBioAssay FAILED TestSpotImages FAILED TestDbControl 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 ++29 tests failed! ++78 tests succeeded!
comment:9 by , 8 years ago
I have now compared the databases generated with Hibernate 5.0 and Hibernate 5.2. They are identical!
comment:10 by , 8 years ago
(In [7368]) 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!
comment:11 by , 8 years ago
(In [7369]) References #2084: Upgrade to Hibernate 5.2
Hibernate has changed the ID generation implementation. This caused or batchers to create incorrect SQL for PostgreSQL (not tested with MySQL yet). This fixes most of the remaining tests:
TestDbControl FAILED ++1 tests failed! ++106 tests succeeded!
comment:12 by , 8 years ago
The failure in the DbControl
test is in the DbControl.disconnect()
method. It turns out we are using a Hibernate API in a way that it was not intended to be used. From the Hibernate API:
It is considered an error to call this method on a session which was not opened by supplying the JDBC connection and an exception will be thrown.
Ok, we are not getting any exception but it seems that we are now losing changes made to items during the time the DbControl
was not connected. As far as I can tell, we only use this feature in the file upload (there is no need to keep the database connection open during the file upload).
I think we should deprecate the DbControl.disconnect()
and DbControl.reconnect()
methods since there is no way to implement what we want in a generic way. The implementation should be changed to simply not doing anything at all.
Client code that need to disconnect/reconnect should be updated to handle this by using two separate DbControl
instances.
comment:13 by , 8 years ago
comment:14 by , 8 years ago
comment:15 by , 8 years ago
comment:16 by , 8 years ago
comment:17 by , 8 years ago
comment:18 by , 8 years ago
comment:19 by , 8 years ago
comment:20 by , 8 years ago
comment:21 by , 8 years ago
(In [7378]) References #2084: Upgrade to Hibernate 5.2
Getting rid of some more calls to deprecated method. Most have simple replacements, but the various NativeQuery.addXXXX()
are a bit more complicated. Lycklily we can either replace them with a Object[]
return type or by re-adding the possibility to speify a return type (as long as it matches a defined entity). See [7375]. A new test case in TestReporterCloneTemplate
was added to check that this works.
comment:22 by , 8 years ago
comment:24 by , 8 years ago
comment:25 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:26 by , 8 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Database schema update is not working when adding a column to an existing table. The generated SQL statement has no quotes around the table which is causing an exception.
org.postgresql.util.PSQLException: ERROR: relation "public.news" does not exist at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2412) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2125) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:297) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:428) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:354) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:301) at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:287) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:264) at org.postgresql.jdbc.PgStatement.executeUpdate(PgStatement.java:244) at com.mchange.v2.c3p0.impl.NewProxyStatement.executeUpdate(NewProxyStatement.java:410) at net.sf.basedb.core.hibernate.SchemaGenerator.execute(SchemaGenerator.java:173) at org.hibernate.jdbc.WorkExecutor.executeWork(WorkExecutor.java:37) at org.hibernate.internal.SessionImpl$1.accept(SessionImpl.java:2321) at org.hibernate.internal.SessionImpl$1.accept(SessionImpl.java:2318) at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.coordinateWork(JdbcCoordinatorImpl.java:314) at org.hibernate.internal.SessionImpl.doWork(SessionImpl.java:2340) at org.hibernate.internal.SessionImpl.doWork(SessionImpl.java:2325) at net.sf.basedb.core.HibernateUtil.createStaticTables(HibernateUtil.java:769) at net.sf.basedb.core.Install.createTables(Install.java:139) at net.sf.basedb.install.InitDB.main(InitDB.java:75)
comment:27 by , 8 years ago
(In [7391]) References #2084: Upgrade to Hibernate 5.2
Implemented a workaround for the unquoted table name problem. It is a bit of a "hack" that involves replacing a private and final variable inside a Hibernate class with our own implementation that forces names to be quoted. We do this only when doing a database schema update and revert to the original value afterwards.
comment:28 by , 8 years ago
comment:29 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:30 by , 7 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Schema update still does not work with !MySQL. I am getting:
ERROR SchemaGenerator:252 - Schema update failed while executing: create table `AnnotationSets` (`id` integer not null auto_increment, `version` integer not null, `item_type` integer not null, `item_id` integer, primary key (`id`)) engine=InnoDB com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'annotationsets' already exists
With logging enabled I also get:
INFO InformationExtractorJdbcDatabaseMetaDataImpl:508 - HHH000262: Table not found: `AnnotationSets` // ... and a lot more for each of the already existing tables
I think it is a problem with upper- vs. lower-casing of table names which Hibernate is not handling correctly.
comment:31 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Seems to be working now after testing with both PostgreSQL and MySQL.
(In [7362]) References #2084: Upgrade to Hibernate 5.2
Replaced old JAR files with new versions. Causes 131 compile errors and 1477 warnings.