-->
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: A question on using Hibernate Native SQL
PostPosted: Fri Sep 15, 2006 12:47 pm 
Newbie

Joined: Tue Sep 12, 2006 2:20 pm
Posts: 6
I am just trying out Hibernate Native SQL. Here is the section of my java code in my test class:


SQLQuery insurance = session.createSQLQuery(
"select * from ENTITLEMENTTYPE");
for (Iterator it = insurance.list().iterator(); it.hasNext();) {
System.out.println(it.next().toString());
}


It gives error:

SEVERE: [IBM][CLI Driver][DB2/NT] SQL0204N "ZHOUP.ENTITLEMENTTYPE" is an undefined name. SQLSTATE=42704

If I specify the correct schema name above, the error goes away. Is there a way so that I don't have to specify the schema name here????

FYI, I DO have a property set up in hibernate.cfg.xml:
<property name="hibernate.default_schema">SCI</property>
And rest of other stuff working fine for me, such as HQL.

Can anyone help? thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 1:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh, that is a DB2 native question. not related to hibernate.

how would you avoid referring to the schema in raw JDBC ?

(hint: by logging in with a user that has the schema as default)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 1:32 pm 
Newbie

Joined: Tue Sep 12, 2006 2:20 pm
Posts: 6
Since I am using db2, are you saying that there is absolutely no way to config Hibernate so that I don't have to refer db2 table with schema name in using Hibernate Native SQL? Just need a firm answer. I know the trick you are mentioning here.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 15, 2006 5:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no, it should work just fine if the user you log in with has that schema as the default.

What do you want us to do otherwise ? randomly inject default schemanames into your native sql ? :)

_________________
Max
Don't forget to rate


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.