Home > Net >  HSQL DB in Spring/Hibernate/JPA - unable to change schema
HSQL DB in Spring/Hibernate/JPA - unable to change schema

Time:09-23

I am using HSQL in memory Db for unit testing Java code. Its configured and brought up using Hibernate/JPA/Spring By default its schema is PUBLIC. However the code I am testing has hardcoded schema. So I need to change the schema from PUBLIC to say ABC

I just figure out how to do it. I tried below approaches

  1. CRATE SCHEMA ABC, SET INITIAL SCHEMA ABC

  2. ALTER CATALOG RENAME PUBLIC TO ABC

I get the error 'Schema not found'

That led me to conclude that once setup and started, we cant change the schema. So I tried with configuring schema as a Entity Manager JPA property at env setup. I started getting 'Dependent Bean not found' error for one of the classes in "domain.packages.to.scan"

I searched a lot on the web, I couldnt find definitive answers on how to accomplish this ?

CodePudding user response:

The simplest way is to rename the PUBLIC schema. Just use the correct syntax from http://hsqldb.org/doc/2.0/guide/databaseobjects-chapt.html#dbc_renaming

ALTER SCHEMA PUBLIC RENAME TO ABC

You can always rename the schema or change to a different schema that you create.

  • Related