Hibernate version: 2.1.8
Name and version of the database you are using: DB2 7
I am attempting to use a fairly complex native sql query for a legacy database and was wondering if there was a built in way for Hibernate to fill in the schema name of the database tables. When doing HQL, Hibernate adds the schema name nicely to its generated SQL, but with native SQL queries, it does not do that. It's pretty obvious that it wouldn't be trivial for Hibernate to attempt to find out where to put the schema name in the query, but is there some sort of flag that I can use to tell Hibernate to put the schema name here? Or is the best way for me to add it as a named parameter? I just want to make sure I'm doing it correctly. If there's a built in way, I want to do it that way. The main reason that this is an issue is that our schema names change depending on what environment (tier) we are on (i.e. the schema name for our development tier is different from our QA tier).
So I would Hibernate to do this automatically if possible:
Code:
SELECT *
FROM my_table
to become this:
Code:
SELECT *
FROM myschema.my_table
Thanks for your help.
--joatmon