Meeti Sharma
Meeti Sharma

Reputation: 1122

How set schema name dynamically in @Table annotation

I have two schema "schema1" and "schema2" and also have two projects. Some of tables are in schema2 that are saving through schema1 project with annotation

@Table(name = "table", schema = "schema2") 

where I mention schema name. But now my requirement is I want to specify schema dynamically in annotation So Suggest 1. Is it possible to specify schema name in runtime 2. and If possible how can we achieve it?

Upvotes: 5

Views: 1710

Answers (1)

You can move schema to hibernate config properties file and use two different hibernate config file for two project

File 1

      hibernate.default_schema=schema1

File 2

      hibernate.default_schema=schema2

Upvotes: 1

Related Questions