Migrating from Hibernate 4 to 5

We’ve got a legacy application which needs upgrade from Hibernate 4.2.0 to 5.4.28.

We went through the Github https://github.com/hibernate/hibernate-orm/blob/5.0/migration-guide.adoc reference. It definitely gives some direction, but we couldn’t find specific direction on changes to be made for, few examples below -

  • public Dialect resolveDialect(DatabaseMetaData dbMetaData) now seems to be used as
    public Dialect resolveDialect(DialectResolutionInfo arg0)
  • org.hibernate.service.jdbc.dialect.spi.DialectResolver now to be used as org.hibernate.engine.jdbc.dialect.spi.DialectResolver
  • org.hibernate.hql.spi.ParameterTranslations methods - getNamedParameterNames(), getOrdinalParameterSqlLocation(int paramInt), getOrdinalParameterExpectedType(int paramInt) - what has these methods been changed to?

We searched for some guidelines for these specific migration points, but couldn’t get any references.

Not relevant to our application, but, the guidelines for migration for hibernate-search as seen in Migration Guide from Hibernate Search 4.x to 5.0 - Hibernate Search seems to be a little more elaborate.

Requesting help on any references/guideline docs which give a little more detailed pointers for upgrading from Hibernate 4.2.0 to 5.4.28.


What kind of guidance are you seeking?

  1. There is an implementation that takes a DatabaseMetaData as constructor argument called DatabaseMetaDataDialectResolutionInfoAdapter, so the previously exposed DatabaseMetaData is wrapped in a dedicated contract.
  2. Well, it was renamed, so what is the question here?
  3. As you can see in the new interface, there are getNamedParameterInformationMap and getPositionalParameterInformation that should give you all information that you need.

Thanks for the direction given regarding DatabaseMetaData and on getNamedParameterInformationMap and getPositionalParameterInformation. We could work on needful modifications with this.

Adding these few more migration points, that have got unearthed, which are making us a bit nervous.
The way things are happening with the codebase we work on now, with regard to this Hibernate upgrade, we are working through compilation errors of the Hibernate libraries, as it happens, and then trying to fix them somehow stumbling upon solutions on net.

Our basic question is, are there any must-read references that need to be looked into, as one sets out on this upgrade activity? We are a bit unsure and apprehensive of the effort that we’d have to put in, with the action-mode that we are in now. Would there any further references other than hibernate-orm-blob-5.0-migration-guide.adoc?


All the changes that happened were in SPIs or internals which are subject to change from time to time in minor and especially in major releases. Usually, it is pretty easy to follow the changes if you look into the issue tracker for the respective versions which as far as I can say, contain all the SPI changes in some form. If you want to rely on these contracts, you will have to adapt your code base from time to time according to this process. We only guarantee backwards compatibility and document migration steps for user facing APIs which SPIs clearly are not. SQLQuery was replaced with org.hibernate.query.NativeQuery