-->
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.  [ 1 post ] 
Author Message
 Post subject: Parameter index out of range (1 > number of parameters...
PostPosted: Wed May 27, 2009 9:35 am 
Newbie

Joined: Fri Aug 08, 2008 9:00 am
Posts: 5
Hey,

I've got a really strange Exception here. Environment is: Hibernate 3.2.6 (I already swiched to 3.3.1) / MySQL 5.1, / GlassFish 2.1 / Windows XP. I deployed my WAR-File including Hibernate-jars.

The exception appears, when this JPQL-Statement is called:

Code:
Query query = em.createQuery( "SELECT t FROM " + getParameterClass().getSimpleName() + " t WHERE t.uid=:uid" );
query.setParameter( "uid", uid );

List<E> entityList = query.getResultList();


(I know it's no good idea to create queries by concatenating strings, but it makes no difference here)

What Hibernate does is:

1.) perform the SQL-Statement to receive the id:

DEBUG [main] org.hibernate.SQL: select person0_.id as id0_, person0_1_.address_id as address4_0_, person0_1_.uid as uid0_, person0_1_.version as version0_, person0_.assistant as assistant8_, person0_.leader as leader8_ from person person0_ inner join abstractentity person0_1_ on person0_.id=person0_1_.id where person0_1_.uid=?
2009-05-27 15:16:44,468 DEBUG [main] org.hibernate.type.StringType: binding 'PMU' to parameter: 1
2009-05-27 15:16:44,468 DEBUG [main] org.hibernate.type.LongType: returning '50' as column: id0_
2009-05-27 15:16:44,468 DEBUG [main] org.hibernate.type.LongType: returning null as column: address4_0_
2009-05-27 15:16:44,468 DEBUG [main] org.hibernate.type.StringType: returning 'PMU' as column: uid0_
2009-05-27 15:16:44,468 DEBUG [main] org.hibernate.type.LongType: returning null as column: version0_
2009-05-27 15:16:44,468 DEBUG [main] org.hibernate.type.BooleanType: returning 'false' as column: assistant8_
2009-05-27 15:16:44,468 DEBUG [main] org.hibernate.type.BooleanType: returning 'false' as column: leader8_

2.) receive the data for entity with id 50:

org.hibernate.SQL: select attributem0_.Entity_id as Entity1_3_, attributem0_.Attribute_id as Attribute2_3_, attributem0_.mapkey_id as mapkey3_3_, abstractat1_.id as id4_0_, abstractat1_.timestamp as timestamp4_0_, abstractat1_.type_id as type3_4_0_, abstractat1_1_.value as value5_0_, abstractat1_4_.value as value11_0_, abstractat1_5_.value as value12_0_, abstractat1_6_.value as value13_0_, case when abstractat1_1_.id is not null then 1 when abstractat1_2_.id is not null then 2 when abstractat1_3_.id is not null then 3 when abstractat1_4_.id is not null then 4 when abstractat1_5_.id is not null then 5 when abstractat1_6_.id is not null then 6 when abstractat1_.id is not null then 0 end as clazz_0_, attributet2_.id as id14_1_, attributet2_.attributeClass as attribut2_14_1_, attributet2_.description as descript3_14_1_, attributet2_.editable as editable14_1_, attributet2_.name as name14_1_, attributet2_.role as role14_1_, attributet2_.subType_id as subType7_14_1_, attributet3_.id as id14_2_, attributet3_.attributeClass as attribut2_14_2_, attributet3_.description as descript3_14_2_, attributet3_.editable as editable14_2_, attributet3_.name as name14_2_, attributet3_.role as role14_2_, attributet3_.subType_id as subType7_14_2_ from abstractentity_abstractattribute attributem0_ left outer join abstractattribute abstractat1_ on attributem0_.Attribute_id=abstractat1_.id left outer join stringattribute abstractat1_1_ on abstractat1_.id=abstractat1_1_.id left outer join mapattribute abstractat1_2_ on abstractat1_.id=abstractat1_2_.id left outer join listattribute abstractat1_3_ on abstractat1_.id=abstractat1_3_.id left outer join dateattribute abstractat1_4_ on abstractat1_.id=abstractat1_4_.id left outer join clobattribute abstractat1_5_ on abstractat1_.id=abstractat1_5_.id left outer join blobattribute abstractat1_6_ on abstractat1_.id=abstractat1_6_.id left outer join attributetype attributet2_ on abstractat1_.type_id=attributet2_.id left outer join attributetype attributet3_ on attributet2_.subType_id=attributet3_.id where attributem0_.Entity_id=?
2009-05-27 15:16:44,484 DEBUG [main] org.hibernate.type.LongType: binding '50' to parameter: 1
2009-05-27 15:16:44,500 DEBUG [main] org.hibernate.type.LongType: returning '348' as column: id4_0_
...lot's of returning bla as bla...
2009-05-27 15:16:44,718 DEBUG [main] org.hibernate.type.TimestampType: returning null as column: timestamp4_0_
2009-05-27 15:16:44,718 DEBUG [main] org.hibernate.type.LongType: returning '140' as column: type3_4_0_

When I perform this query manually on mysql it works without a problem. But Hibernate throws the following Exception afterwards:

2009-05-27 15:16:44,765 WARN [main] org.hibernate.util.JDBCExceptionReporter: SQL Error: 0, SQLState: S1009
2009-05-27 15:16:44,765 ERROR [main] org.hibernate.util.JDBCExceptionReporter: Parameter index out of range (1 > number of parameters, which is 0).
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not initialize a collection: [de.timetoact.employeepages.model.AbstractEntity.attributeMap#50]
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:637)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:74)
at de.timetoact.employeepages.gateway.impl.GenericGatewayImpl.getEntityByUid(GenericGatewayImpl.java:141)
at de.timetoact.employeepages.gateway.impl.PersonGatewayImpl.getPersonByUid(PersonGatewayImpl.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:138)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy33.getPersonByUid(Unknown Source)
at de.timetoact.employeepages.gateway.impl.PersonHelpGatewayImpl.createUid(PersonHelpGatewayImpl.java:350)
at de.timetoact.employeepages.gateway.impl.PersonHelpGatewayImpl.createPersistentRandomEntity(PersonHelpGatewayImpl.java:145)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:138)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy36.createPersistentRandomEntity(Unknown Source)
at de.timetoact.employeepages.webclient.test.TestDB.main(TestDB.java:94)
Caused by: org.hibernate.exception.GenericJDBCException: could not initialize a collection: [de.timetoact.employeepages.model.AbstractEntity.attributeMap#50]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadCollection(Loader.java:2001)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:63)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:454)
at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:844)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:241)
at org.hibernate.loader.Loader.doList(Loader.java:2213)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:65)
... 31 more
Caused by: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.PreparedStatement.checkBounds(PreparedStatement.java:3326)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3310)
at com.mysql.jdbc.PreparedStatement.setString(PreparedStatement.java:4146)
at com.mysql.jdbc.BlobFromLocator.length(BlobFromLocator.java:329)
at org.hibernate.type.ByteArrayBlobType.get(ByteArrayBlobType.java:89)
at org.hibernate.type.AbstractLobType.nullSafeGet(AbstractLobType.java:46)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2101)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1380)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1308)
at org.hibernate.loader.Loader.getRow(Loader.java:1206)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580)
at org.hibernate.loader.Loader.doQuery(Loader.java:701)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1994)
... 47 more
de.timetoact.employeepages.gateway.exception.EpGatewayException: An error occurs while getting person by uid PMU
at de.timetoact.employeepages.gateway.impl.GenericGatewayImpl.getEntityByUid(GenericGatewayImpl.java:162)
at de.timetoact.employeepages.gateway.impl.PersonGatewayImpl.getPersonByUid(PersonGatewayImpl.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:138)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy33.getPersonByUid(Unknown Source)
at de.timetoact.employeepages.gateway.impl.PersonHelpGatewayImpl.createUid(PersonHelpGatewayImpl.java:350)
at de.timetoact.employeepages.gateway.impl.PersonHelpGatewayImpl.createPersistentRandomEntity(PersonHelpGatewayImpl.java:145)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:138)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy36.createPersistentRandomEntity(Unknown Source)
at de.timetoact.employeepages.webclient.test.TestDB.main(TestDB.java:94)

The query has exactly one WHERE-clause and one parameter is assigned.

What makes the problem even stranger, is that i can deploy my Application on other environments (Linux, Mac) and it works.

Does anyone see the problem here?

Thanks in advance!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.