-->
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.  [ 4 posts ] 
Author Message
 Post subject: Native SQL queries and schema name
PostPosted: Wed Mar 09, 2005 5:37 pm 
Newbie

Joined: Mon Dec 13, 2004 5:27 pm
Posts: 7
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 10, 2005 9:59 am 
Newbie

Joined: Mon Dec 13, 2004 5:27 pm
Posts: 7
bumping, hoping for answer.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 10, 2005 1:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no such thing built in.

ant does a terrific job at replacing stuff in configurationfiles - i would recommend you use that for this.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 10, 2005 4:07 pm 
Newbie

Joined: Mon Dec 13, 2004 5:27 pm
Posts: 7
Thank you. I appreciate the response!

--joatmon


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

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.