How to Configure Alternate DB Schema for JPAServer Auto-DDL Creation in Postgres

43 views
Skip to first unread message

Ryck Birch

unread,
Mar 29, 2023, 2:17:18 PM3/29/23
to HAPI FHIR
Hi folks:

Newbie here with HAPI-FHIR-JPAServer. I am trying to trying to hook up the JPAServer to Postgres. This I can do.

However, I cannot figure out how to direct the application on initialization for the DB to use something other than the "Public" default Postgres schema.

Can this be configured? How does one do it?

Any help much appreciated!!
Ryck

btab...@meditech-int-services.com

unread,
Mar 29, 2023, 11:10:57 PM3/29/23
to HAPI FHIR
Hey Ryck

I believe you need to modify the connection URL used by HAPI-FHIR-JPAServer to specify the schema you want to use.
The connection URL is typically specified in the persistence.xml file located in the META-INF directory of your application.
Assuming you are using Hibernate as your JPA provider, you can modify the hibernate.default_schema property in persistence.xml

Hope that helps

Ryck Birch

unread,
Mar 30, 2023, 9:28:45 AM3/30/23
to HAPI FHIR
Hey my friend!

Your suggestion got me the rest of the way there... Here's how:
  1. Created my new target schema in Postgres
  2. In the Application.yaml file [src\main\resources\application.yaml], updated the Spring:datasource:url (spring.datasource.url) to include the schema as a query parameter--> url: ' jdbc:postgresql://localhost:5432/mydatabase?currentSchema=myschema'
  3. Turned on the JPAServer and everything spun up perfectly.
Can't thank you enough and for your generosity in a quick suggestion turn around.

Ryck

Reply all
Reply to author
Forward
0 new messages