Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
[b]Hibernate version:[/b] 3.0.5
[b]Name and version of the database you are using:[/b] DB2 for z/OS 7.0
Hi,
I suspect that the answer to my question is "no, Hibernate can't help you", but here's what I'm trying to do.
I'm working with a DB2 environment where the schema qualifier of the tables is different in different stages (e.g. DSCHEMA for the Dev stage, TSCHEMA for the Test stage, etc.). In all the Hibernate code I've written so far, I leave the table name of the mapping files unqualified, and I set the global Schema name at run time when I configure my session factory, like so:
Configuration configuration = new Configuration();
configuration.configure();
Properties properties = new Properties();
properties.put( Environment.DEFAULT_SCHEMA,
getDefaultSchema());
configuration.addProperties(properties);
That's worked just swell for me so far. The Hibernate configuration file doesn't change from stage to stage, but a separate properties file does, and Hibernate correctly prepends the schema on to the table name before issuing an sql command.
Now I'm trying something a bit more fancy -- I want to create a class mapped to a "subselect". My subselect looks like this:
<subselect>
select distinct foo, bar
from FOOBAR
</subselect>
My problem is that Hibernate doesn't try to qualify FOOBAR with my schema name, which results in this SQL error:
WARN : [2005-09-14 12:10:55,609] org.hibernate.util.JDBCExceptionReporter - SQL Error: -204, SQLState: 42704
(I'm guessing that Hibernate doesn't try to parse the subselect statement, looking for table names or the like)
Can I:
1. set some configuration to allow Hibernate to qualify the table; or
2. intercept the set-up of the mapping file at run time to manipulate the subselect string in Java code?
Any suggestions would be greatly appreciated.