-->
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.  [ 2 posts ] 
Author Message
 Post subject: Native SQL "in" does not work properly
PostPosted: Fri Jul 23, 2010 4:57 am 
Newbie

Joined: Fri Jul 23, 2010 4:50 am
Posts: 2
Hello dear community.

I would like to use sql's "in" function for selecting something but it delivers wrong results.
When i perform the same command directly on the database, it works fine:

the command should be this:
Code:
SELECT count( * )
FROM productcategory_product
WHERE `productcategoryid`
IN ( 2, 3 )

delivering a result of 8.

with hibernate, I created this command:

Code:
results = (BigInteger) getSession().createSQLQuery("select count(*) as productSum from " + ProductCategoryDO.PRODUCT_RELATION_TABLE + " where " + ProductCategoryDO.PRODUCT_RELATION_COLUMN + " in (:productIdList)")
            .setParameter("productIdList", idString).uniqueResult();


where productIdList is "2,3".

unfortunately, it always delivers 7 as result.
My table looks like this:

Code:
productcategoryid    productid
2    1
2    2
2    3
2    4
2    5
2    6
2    7
3    8

Do you might know what to do?


Top
 Profile  
 
 Post subject: Re: Native SQL "in" does not work properly
PostPosted: Mon Jul 26, 2010 2:44 am 
Newbie

Joined: Fri Jul 23, 2010 4:50 am
Posts: 2
So does someone has a hint for me?


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