-->
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.  [ 3 posts ] 
Author Message
 Post subject: setting schema name for native queries
PostPosted: Tue Jun 05, 2007 6:08 am 
Newbie

Joined: Tue Jun 05, 2007 5:03 am
Posts: 2
Hi ,
inside my hibernate.cfg.xml I am mentioning
hibernate.default_schema as schema name (say "testSchema") and it is working with named queries and HQL as expected.But when I am using a native sql query ,say

String queryString= 'select field1 from table1 where field2=100';
SQLQuery queryObj=session.createSQLQuery(queryString).
addScalar("field1 ",Hibernate.STRING);

In that case the schema name(i.e. testSchema)is not getting appended to the table names.
As a work around I had to add the schema name before the table names.
So the changed code is ,
String queryString= 'select field1 from testSchema.table1 where field2=100';
.....

But it is not the correct approach I guess.If there are 100 queries
and in future my schema name changes, I have to change the schema name at 100 places.
Can anybody provide me the correct implementation ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 07, 2007 2:46 am 
Newbie

Joined: Tue Jun 05, 2007 5:03 am
Posts: 2
Any hint from anybody ? Even if it is not there in Hibernate just tell me that.It is little bit urgent for me .
Regards,
Ayan


Top
 Profile  
 
 Post subject: Re: setting schema name for native queries
PostPosted: Tue Aug 25, 2009 10:04 am 
Beginner
Beginner

Joined: Fri Sep 12, 2008 10:55 am
Posts: 33
I know it's been over 2 years, but I'm now seeing this issue. We have a native query, and I have to insert the schema name, rather than being applied via the hibernate.default_schema. Is this a bug?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.