-->
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: SQL Query against a Stored Procedure
PostPosted: Sat Feb 07, 2004 10:41 pm 
Regular
Regular

Joined: Wed Dec 31, 2003 4:26 am
Posts: 108
Location: Berkeley, CA
I'm unable to get the following query to work from within Hibernate:
Code:
select distinct item.varchar_value_5 from merchandise.ds_item(6) as item;

I've tried a variety of approaches, including:
Code:
session.createSQLQuery(
         "SELECT {item}.varchar_value_5 FROM merchandise.ds_item(6) as {item}",
         "item",
         com.publishworks.merchandise.Item.class
      ).list();

Which produces a
[java] java.lang.NullPointerException
Complaining:
[java] org.postgresql.util.PSQLException: The column name dsrc_id0_ not found.
Yes, dsrc_id is part of the primary key for item.

So it seems that, quite naturally, hibernate wants to create the item object (or at least its id) when using an {item} reference in a query.

I noticed, however, that hibernate does support querys like:
Code:
select distinct cat.name from eg.Cat cat

And am wondering if there is a way to get similar support with direct sql without dropping down to jdbc.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 08, 2004 4:20 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No, there is no way besides using plain old JDBC.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2004 4:14 am 
Regular
Regular

Joined: Wed Dec 31, 2003 4:26 am
Posts: 108
Location: Berkeley, CA
Meanwhile, I found a strange, hackish way. Basically I define a "mapping" to a java.lang.String type from a non-existent table. The mapping declares a string (the string) as the id. Basically, that does the trick. Doesn't save much over JDBC and of course needless to have Hibernate involved, etc, but it does work.


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.