Reputation: 14879
Is it possible for me to set the schema dynamically with Hibernate?
On the same web page (session), I want the ability to alter the schema potentially per query I make.
Is this possible?
i.e. on each DAO method I will pass the name of the schema to connect to.
Upvotes: 0
Views: 1151
Reputation: 78443
You can set the search path, e.g.:
SET search_path TO 'schemaname,public'
If you just need this for a single query, you can do that in two ways:
Run two queries, one to set the search_path
and the other for your actual query. If you do this, don't forget to do this in subsequent queries, as they'll be affected too).
Change your query so it selects from schemaname.tablename
rather than plain tablename
.
Upvotes: 1