-->
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: named native sql query generated wrong, a bug?
PostPosted: Mon Sep 26, 2005 2:53 pm 
Newbie

Joined: Wed Apr 13, 2005 8:10 am
Posts: 15
Hi,

Before submitting a Jira Issue I wanted to ask here, maybe someone came across this.

Using Hibernate 3 with a postgresql dialect, I define the following query:

Code:
<sql-query name="manufacturers-specifying-properties">
   <return-scalar column="mid" type="integer"/>
   <return-scalar column="pid" type="integer"/>
      SELECT m.manufacturer_id AS mid, p.fk_property_id AS pid
        FROM templates.manufacturer m
              INNER JOIN templates.manufacturer_property p
                 ON m.manufacturer_id = p.fk_manufacturer_id
       WHERE ( m.fk_manufacturer_type_id in :types )
             AND  ( p.fk_property_id in :properties )
</sql-query>


in my code I use

Code:
query.setParameterList( "types", manTypeIds , Hibernate.LONG);
query.setParameterList( "properties" , manufacturerIds, Hibernate.LONG );


Where both parameters are collections (in fact lists of Longs).

Now hibernate produces a bad query:

Code:
SELECT m.manufacturer_id AS mid, p.fk_property_id AS pid FROM templates.manufacturer m INNER JOIN templates.manufacturer_property p ON m.manufacturer_id = p.fk_manufacturer_id WHERE ( m.fk_manufacturer_type_id in ) AND ( p.fk_property_id in ?, ? )


Note that both question marks are at the end of the query, which results in an error. I suspect it is a bug...

When I use query.setParameter(...) instead of setParameterList(...), the question marks are at the right place, but the query would result in another error...

Any clues someone?
Cheers,
Ron


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 3:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
sounds like a bug yes.

we should be able to handle i afaik.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 4:56 pm 
Newbie

Joined: Wed Apr 13, 2005 8:10 am
Posts: 15
Would you fill a Jira issue?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 1:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
No, you do that ;)

_________________
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.