简体   繁体   中英

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

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM