-->
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: Does Restrictions.in work correctly with composite ids?
PostPosted: Wed Sep 28, 2005 11:16 am 
Beginner
Beginner

Joined: Thu Sep 15, 2005 4:16 pm
Posts: 29
Here's the question. I create dynamic classes and map them by generating configurations. I use a composite-id element for the primary key. I then would like to load a set of these objects in one go. Loading using get works fine, which leads me to think that the object mapping is correct.

My first attempt to load using criteria was to use Restrictions.in("id",listofids) where listofids is a list of the composite-id representation class. The generated SQL had the where clause below, the rest of the generated SQL looked normal.

I use Restrictions.in successfully with simple keys, so I know it normally works. It this behavior a known restriction, a known bug or a new bug?


Hibernate version:
3.1

Name and version of the database you are using:
SQL Server

The generated SQL (show_sql=true):
Simplified it generated a where clause with:

(CONTENTID,REVISIONID) in ((?,?))


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 28, 2005 11:52 am 
Newbie

Joined: Sat Jul 23, 2005 8:31 am
Posts: 18
i son't see the problem, for me it looks like it behaves correctly.
if you have a list of three items and not only one like now it should look like:
(CONTENTID,REVISIONID) in ((?,?), (?,?), (?,?))
i didn't test it but as much as i know this is correct.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 28, 2005 12:09 pm 
Beginner
Beginner

Joined: Thu Sep 15, 2005 4:16 pm
Posts: 29
Well perhaps this is a dialect issue, but doing a query like that in SQL Server generates an error. So, no, it isn't OK.

For example:

SELECT *
FROM RXS_CT_GENERIC
WHERE (CONTENTID, REVISIONID) IN ((335, 1), (336, 1))

causes SQL Server to complain about incorrect syntax near ','. This also happens with no values, so it looks like it doesn't like (CONTENTID,REVISIONID)

I was looking through the documentation for SQL Server and didn't see any "IN" operator example that did any sort of composite in clause. I was able to code around my problem by using a set of OR'd conditions. I don't know if there's an efficiency advantage of one over the other.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 06, 2006 9:36 am 
Newbie

Joined: Tue May 23, 2006 5:53 am
Posts: 3
I noticed that the criteria API inserts the replacements parameters in the wrong order, this may be the problem


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.