Opened 12 years ago
Closed 10 years ago
#1742 closed task (fixed)
Upgrade to Hibernate 4.x
Reported by: | Nicklas Nordborg | Owned by: | Nicklas Nordborg |
---|---|---|---|
Priority: | critical | Milestone: | BASE 3.4 |
Component: | core | Version: | |
Keywords: | Cc: |
Description
Hibernate 4 has been around for quite some time now, but I have been reluctant to update, since I fear that it may affect/break a lot of things in BASE. Possible even things that are exposed as out public API.
It seems like the Hibernate developers are now working on Hibernate 5 (https://community.jboss.org/wiki/HibernateRoadmap) and that the 3.6.x branch is more or less abandoned. Sooner or later we have to update to a newer Hibernate, and it is usually better to do it sooner...
Change History (21)
comment:1 by , 10 years ago
Milestone: | BASE Future Release → BASE 3.4 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:2 by , 10 years ago
comment:3 by , 10 years ago
comment:4 by , 10 years ago
comment:5 by , 10 years ago
comment:6 by , 10 years ago
comment:7 by , 10 years ago
comment:8 by , 10 years ago
comment:9 by , 10 years ago
comment:10 by , 10 years ago
comment:11 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:12 by , 10 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
When updating a MySQL installation from 3.3 to 3.4 Hibernate generates several pairs of SQL statemtents for re-creating unique indexes:
alter table `Annotations` drop constraint Annotation_uniquetype alter table `Annotations` add constraint Annotation_uniquetype unique (`annotationset_id`, `annotationtype_id`)
The first statement fails because MySQL don't like the 'constraint' keyword:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'constraint Annotation_uniquetype' at line 1
To fix the SQL, 'constraint' should be replaced with 'index', but then another problem arises, there is no index with the name Hibernate tries to drop so the SQL fails in any case.
comment:13 by , 10 years ago
As it turns out things seems to not be ok on PostgreSQL either. I have duplicate indexes with names:
- Annotations_annotationset_id_annotationtype_id_key
- annotation_uniquetype
But this is on an old database and I am not exactly sure how this has happened or why the "drop constraint" command didn't fail (due to a non-existing index) on PostgreSQL in the first place.
More testing is needed.
comment:14 by , 10 years ago
I checked updating a BASE 3.3 to 3.4 on PostgreSQL and it works. To begin with there is only one index (Annotations_annotationset_id_annotationtype_id_key). The updated creates the other index and the reason that the drop command doesn't fail is that it uses the 'if exists' syntax:
alter table "Annotations" drop constraint if exists Annotation_uniquetype
So the way forward would be something like:
- For MySQL fix the drop command so that it works and actually drops the index if it exists.
- Implement support for the
SchemaUpdateScript.isQuiet()
method (eg. ignore exceptions if TRUE). - Implement a feature that checks for duplicate indexes and remove all but one of them (keep the one with the shortest name). Can probably be done by the
updateindexes.sh
script.
comment:15 by , 10 years ago
comment:16 by , 10 years ago
comment:17 by , 10 years ago
comment:18 by , 10 years ago
comment:19 by , 10 years ago
(In [6672]) References #1742: Upgrade to Hibernate 4.x
XDoclet generation of Hibernate mapping files generated error messages for files not containing andy hibnernate mapping annotations and not specified in build.xml as something that should be parsed.
Solved by copying net/sf/based/core/data/* to a temporary directory before running XDoclet on only the files in the temporary directory.
comment:20 by , 10 years ago
comment:21 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
(In [6468]) References #1742: Upgrade to Hibernate 4.x
Updated to Hibernate 4.3.5.
HibernateUtil.doJdbcWork()
replaced withHibernateUtil.doWork()
andHibernateUtil.doReturningWork()
since Hibernate now has built-in support for return information from a work. RemovedJdbcWork
and lots of other changes needed because of this.EntityMode
parameter is no longer needed in lots of methods (I guess Hibernate has dropped support for other modes than POJO).Quota.quotaValues
changed fromMap
toSet
since I could not get the map implemenation to work with Hibernate. ThemaxBytes
property is now part ofQuotaIndex
.So far I have tested installation and
TestAll
on PostgreSQL. Need to test MySQL and updating also.There are also some remaining calls to deprecated methods in Hibernate.