-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: subselect without specifying schema
PostPosted: Wed Sep 14, 2005 12:38 pm 
Newbie

Joined: Wed Sep 14, 2005 12:17 pm
Posts: 13
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.