-->
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: Error while using IN with array of items.
PostPosted: Thu Mar 27, 2008 11:18 am 
Newbie

Joined: Tue Mar 18, 2008 12:37 pm
Posts: 4
I'm having a problem while making an HQL query with some classes which are equivalent to these ones:

Code:
public class Person{
   private String name;
   private String lastName;
   ... //getter & setter
   }
   
public class Employer{
   private int id;
   private Person employerDetails;
   private int role;
   ... //getter & setter
   }


I'm mapping the Emplyer class over a table, with the employerDetails component mapped as a <component>.

The problem i'm seeing arises when i try to make the following HQL query:

Code:
SELECT employer
FROM Employer as employer
WHERE (employer.employerDetails) IN (:personList)


Where :personList is associated to an Array of Person objects.
When it gets translated into sql for DB2, it looks like this:

Code:
WHERE ((employer0_.EMPNAME, employer0_.EMPSURNAME) in ((?, ?) , (?, ?)))


Where hibernate correctly tries to fill the remaining ? with the input values from the array.
The problem is that DB2 returns me the following error:

Code:
DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: (;_.EMPNAME) in (;<values>


Which says that it found a "(" past the "_.EMPNAME) in (" part, where it was expecting some <values>.
The whole impression is that I'm either making some errors into the HQL query syntax, or that it gets translated in the wrong way by the hibernate translator.
Any suggestions?


Hibernate version: 3.2.6 GA

Hibernate dialect: org.hibernate.dialect.DB2Dialect


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 28, 2008 7:43 am 
Newbie

Joined: Tue Mar 18, 2008 12:37 pm
Posts: 4
An update over the whole matter...
I've figured out that if i place a VALUES keyword inside the SQL query that gets created, that is, like this:

Code:
WHERE ((employer0_.EMPNAME, employer0_.EMPSURNAME) in (VALUES (?, ?) , (?, ?)))


It works flawlessly.
This sounds more like an Hibernate lack or error, since if i modify in a similar manner the HQL query with a VALUES keyword, it doesn't recognize it. That said, does Hibernate provide a keyword that gets translated as VALUES for DB2? Otherwise, is there any way for me to add the VALUES keyword inside the generated HQL query?
Thanks for any help.


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.