This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

[Hibernate3.0] Filters, DB2 => invalid parameter number  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mapping documents:

<hibernate-mapping>
<class name="cat.eur.fq.bnrrnb.model.Transaction" table="ZT_REC_INTERPLNT" schema="AN0FQ002">

<id name="ident" column="IDENT" type="java.lang.Long" length="11" />

<property (...) />

<filter name="instance" condition=" RCV_FAC_CD = :instanceFacility "/>

</class>

<filter-def name="instance">
<filter-param name="instanceFacility" type="string"/>
</filter-def>

</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():


.enableFilter("instance")
.setParameter("instanceFacility", "37")



Full stack trace of any exception that occurs:

[2005-09-26 14:00:33.022] -1 INFORMATIONAL DBStatement logDebugSQLString select distinct abstractmo0_.SHP_FAC_CD as col_0_0_ from AN0FQ002.ZT_REC_INTERPLNT abstractmo0_ where abstractmo0_.RCV_FAC_CD = '37' and abstractmo0_.MVNT='RCVG'
[2005-09-26 14:00:33.173] 0 FATAL org.hibernate.util.JDBCExceptionReporter java [IBM][JDBC Driver] CLI0612E Invalid parameter number. SQLSTATE=S1093
org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1502)
at org.hibernate.loader.Loader.list(Loader.java:1482)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:365)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:268)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:782)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at cat.eur.fq.bnrrnb.dao.BnrRnbDAOImp.getFacilitiesForMovement(BnrRnbDAOImp.java:63)
at cat.eur.fq.bnrrnb.tests.dao.BnrRnbDAOImpTest.testGetFacilitiesForMovement(BnrRnbDAOImpTest.java:27)
at java.lang.reflect.Method.invoke(Native Method)
at junit.framework.TestCase.runTest(TestCase.java:154)
at cat.euro.test.TUFHbmAbstractTestCase.runTest(TUFHbmAbstractTestCase.java:127)
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: COM.ibm.db2.jdbc.DB2Exception: [IBM][JDBC Driver] CLI0612E Invalid parameter number. SQLSTATE=S1093
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throwParamIndexError(SQLExceptionGenerator.java:626)
at COM.ibm.db2.jdbc.app.DB2PreparedStatement.setString(DB2PreparedStatement.java:2748)
at cat.cis.tuf.server.connector.jdbc.v1.JDBCv1DBStatement.setString(JDBCv1DBStatement.java:1113)
at org.hibernate.type.StringType.set(StringType.java:24)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:62)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:44)
at org.hibernate.loader.hql.QueryLoader.bindNamedParameters(QueryLoader.java:232)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1101)
at org.hibernate.loader.Loader.doQuery(Loader.java:362)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:203)
at org.hibernate.loader.Loader.doList(Loader.java:1499)
... 20 more


Name and version of the database you are using:
DB2V7

The generated SQL (show_sql=true):
select distinct abstractmo0_.SHP_FAC_CD as col_0_0_ from AN0FQ002.ZT_REC_INTERPLNT abstractmo0_ where abstractmo0_.RCV_FAC_CD = '37' and abstractmo0_.MVNT='RCVG'



SO! after all taht, here is my problem:

I try to use the filter at session creation. So I set it.
But, with it set, I get a JDBC error althought the sql statement is ok.
I get a "[IBM][JDBC Driver] CLI0612E Invalid parameter number. SQLSTATE=S1093"...

If I disable the filter, it works fine.

Thanks in advance for any help.
 
Brice Laurencin
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok....

From the hibernate forum, I had a "it is a JDBC driver problem", and I said "no, it's not".

But in fact, it is....

With DB2v7,there are two version of the driver: JDBCv1, and v2. The v2 works like a charm :-/

does anybody has a cliff I could jump off ?
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!