Upgrade fails with SQL Dialect, net.sf.hibernate.dialect.SQLServerDialect
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Problems
Upgrading from 5.9.2 to 5.9.3 fails with the following error message:
2021-05-06 10:56:51,671 INFO [localhost-startStop-1] [confluence.upgrade.ddl.HibernateDdlExecutor] executeDdlStatements Executing DDL: drop table USER_RELATION
2021-05-06 10:56:51,720 INFO [localhost-startStop-1] [confluence.upgrade.ddl.HibernateDdlExecutor] executeDdlStatements Executing DDL: drop table CONTENT_RELATION
2021-05-06 10:56:51,761 INFO [localhost-startStop-1] [confluence.upgrade.ddl.HibernateDdlExecutor] executeDdlStatements Executing DDL: drop table USERCONTENT_RELATION
2021-05-06 10:56:52,437 ERROR [localhost-startStop-1] [hibernate.tool.hbm2ddl.SchemaUpdate] execute Unsuccessful: alter table USER_RELATION add constraint FK_U2URELATION_LASTMODIFIER foreign key (LASTMODIFIER) references user_mapping
2021-05-06 10:56:52,437 ERROR [localhost-startStop-1] [hibernate.tool.hbm2ddl.SchemaUpdate] execute Column 'user_mapping.user_key' is not the same data type as referencing column 'USER_RELATION.LASTMODIFIER' in foreign key 'FK_U2URELATION_LASTMODIFIER'.
2021-05-06 10:56:52,437 ERROR [localhost-startStop-1] [hibernate.tool.hbm2ddl.SchemaUpdate] execute could not complete schema update
java.sql.SQLException: Column 'user_mapping.user_key' is not the same data type as referencing column 'USER_RELATION.LASTMODIFIER' in foreign key 'FK_U2URELATION_LASTMODIFIER'.
Environment
5.9.2
MS SQL Server
Diagnosis
- Check the SQL Dialect in the confluence.cfg.xml has the dialect as the following:
<property name="hibernate.dialect">net.sf.hibernate.dialect.SQLServerDialect</property>
2. Check the USER_RELATION.LASTMIDFIER data type is varchar with the following query:
select COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH from INFORMATION_SCHEMA.COLUMNS where table_name = 'USER_RELATION'
Solution
The issue was caused by the incorrect dialect for the MS SQL server, and it can be fixed by change it to the following:
<property name="hibernate.dialect">net.sf.hibernate.dialect.SQLServerIntlDialect</property>