google / fhir-data-pipes

A collection of tools for extracting FHIR resources and analytics services on top of that data.
https://google.github.io/fhir-data-pipes/
Apache License 2.0
151 stars 84 forks source link

Update Hibernate.dialect for latest HAPI version #970

Closed chandrashekar-s closed 7 months ago

chandrashekar-s commented 7 months ago

Description of what I changed

HAPI has released a latest docker image on 27-Feb-2023. In this version due to some upgrades on the hibernate dependencies, the earlier hibernate dialect setting spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL95Dialect is not working anymore. It results in the below error.

Error logs on start of HAPI server

hapi-server    | Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.dialect.PostgreSQL95Dialect] as strategy [org.hibernate.dialect.Dialect]
hapi-server    |    at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:154)
hapi-server    |    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:129)
hapi-server    |    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
hapi-server    |    ... 118 common frames omitted
hapi-server    | Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.dialect.PostgreSQL95Dialect]
hapi-server    |    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:126)
hapi-server    |    at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:150)
hapi-server    |    ... 128 common frames omitted
hapi-server    | Caused by: java.lang.ClassNotFoundException: Could not load requested class : org.hibernate.dialect.PostgreSQL95Dialect
hapi-server    |    at org.hibernate.boot.registry.classloading.internal.AggregatedClassLoader.findClass(AggregatedClassLoader.java:216)
hapi-server    |    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:592)
hapi-server    |    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
hapi-server    |    at java.base/java.lang.Class.forName0(Native Method)
hapi-server    |    at java.base/java.lang.Class.forName(Class.java:467)
hapi-server    |    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:123)
hapi-server    |    ... 129 common frames omitted

Fix

The latest hapi release supports this dialect ca.uhn.fhir.jpa.model.dialect.HapiFhirPostgresDialect which is the recommended dialect by hapi-fhir.

More details

In the latest hapi release, the artifact ca.uhn.hapi.fhir:hapi-fhir has been upgraded to version 7.0.0. In this 7.0.0 version the HIbernate.version used in 6.4.1.Final. Support for the dialect org.hibernate.dialect.PostgreSQL95Dialect has been removed in this hibernate version and is replaced with org.hibernate.dialect.PostgreSQLDialect. We could have used this dialect instead, but hapi recommends using this ca.uhn.fhir.jpa.model.dialect.HapiFhirPostgresDialect


E2E test

TESTED:

Please replace this with a description of how you tested your PR beyond the automated e2e/unit tests.

Checklist: I completed these to help reviewers :)