hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
1.98k stars 1.3k forks source link

Hibernate Caching Inoperable #3259

Open theGOTOguy opened 2 years ago

theGOTOguy commented 2 years ago

Describe the bug Attempting to enable Hibernate caching causes HAPI to fail to inject essential resources, and the server fails to start.

To Reproduce The behavior is easy to see in the current version of the JPA server.

docker run -e spring.jpa.properties.hibernate.cache.use_query_cache=true hapiproject/hapi:latest

or

docker run -e spring.jpa.properties.hibernate.cache.use_second_level_cache=true hapiproject/hapi:latest

reproduces the behavior. The root error is, e.g.:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [ca/uhn/fhir/jpa/starter/FhirServerConfigR4.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.cache.spi.RegionFactory]

Expected behavior HAPI FHIR should start correctly if caching is enabled.

Environment (please complete the following information):

psavva commented 2 years ago

I can confirm the same

+1

jamesagnew commented 2 years ago

HAPI FHIR JPA is not designed to work with the hibernate 2nd level cache feature. We implement a business level caching layer on top of hibernate (it can be found in MemoryCacheService) which makes the 2nd level cache mostly redundant.