-->
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: Possible bug in Query.setParameterList() in 3.1.2?
PostPosted: Wed Feb 01, 2006 1:40 pm 
Newbie

Joined: Thu Nov 17, 2005 1:44 pm
Posts: 6
Hibernate version:
3.1.2

Hi,

I just updated to from 3.0.5 to 3.1.2 and one of my HQL queries stoped working. The query looks like this:


Code:
String query = "FROM EntitySpecificationValue esv LEFT JOIN FETCH esv.attributes WHERE esv.identifier IN (:ids)";

List res = session.createQuery(query).setParameterList("ids", ids).list();


ids is a List of Long objects. This used to work in 3.0.5 but now I get the following exception:

Code:
org.hibernate.exception.GenericJDBCException: could not execute query
   at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.loader.Loader.doList(Loader.java:2148)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
   at org.hibernate.loader.Loader.list(Loader.java:2024)
   at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
   at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
   at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1129)
   at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
   at com.xxx.se.inventory.dao.EntitySpecificationDaoImpl.getEntitySpecificationsByIds(EntitySpecificationDaoImpl.java:169)
   at com.xxx.se.inventory.dao.EntitySpecificationDaoImpl.getEntitySpecificationsByKeys(EntitySpecificationDaoImpl.java:149)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
   at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
   at $Proxy1.getEntitySpecificationsByKeys(Unknown Source)
   at com.xxx.se.inventory.dao.EntitySpecificationDaoTest.testGetSpecificationsByKeysAndRemove(EntitySpecificationDaoTest.java:156)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
   at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at junit.framework.TestSuite.runTest(TestSuite.java:208)
   at junit.framework.TestSuite.run(TestSuite.java:203)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)
Caused by: java.sql.SQLException: Missing IN or OUT parameter at index:: 1
   at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
   at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
   at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1536)
   at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2900)
   at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:2946)
   at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
   at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
   at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
   at org.hibernate.loader.Loader.doQuery(Loader.java:662)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
   at org.hibernate.loader.Loader.doList(Loader.java:2145)
   ... 36 more


The generated SQL is correct and looks like this:

Code:
select
entityspec0_.ID as ID104_,
entityspec0_.OPTIMISTIC_LOCKING_VERSION as OPTIMISTIC3_104_,
entityspec0_.KIND_ID as KIND4_104_,
entityspec0_.POLYMORPHIC_DISCRIMINATOR as POLYMORP2_104_,
attributes1_.SPEC_ID as SPEC1_0__,
attributes1_.NAME as NAME0__,
attributes1_.ATTR_VALUE as ATTR3_0__,
attributes1_.DISCRIMINATOR as DISCRIMI4_0__

from IPS_SPECIFICATION entityspec0_ left outer join IPS_SPECIFICATION_ATTRIBUTE attributes1_ on entityspec0_.ID=attributes1_.SPEC_ID where entityspec0_.ID in (? , ?)


It works fine if I change my code to look like this:

Code:
String toString = ids.toString();
String params = toString.substring(1, toString.length()-1);
String query = "FROM EntitySpecificationValue esv LEFT JOIN FETCH esv.attributes WHERE esv.identifier IN (" + params + ")";

List res = session.createQuery(query).list();

_________________
Thank you for a Great product!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 01, 2006 6:17 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
two things would be useful:
1) the AST tree
2) corresponding debug log fragments from org.hibernate.type fpr the binds


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 02, 2006 11:36 am 
Newbie

Joined: Thu Nov 17, 2005 1:44 pm
Posts: 6
Ok my bad, sorry! I was actually giving it a list of Strings (not Longs) as argument. I guess org.hibernate.type.NullableType nullSafeSet has changed since 3.0.5 because it worked with a List of Strings with 3.0.5 even though the column was mapped as Long. Anyway, sorry again.

_________________
Thank you for a Great product!


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.