aspose file tools*
The moose likes Object Relational Mapping and the fly likes Not closing pre-bound Hibernate Session after HibernateTemplate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Not closing pre-bound Hibernate Session after HibernateTemplate" Watch "Not closing pre-bound Hibernate Session after HibernateTemplate" New topic
Author

Not closing pre-bound Hibernate Session after HibernateTemplate

zamir arif
Greenhorn

Joined: Nov 21, 2008
Posts: 5
While running my Junit testcase. when I am executing the below code

deposit = depositDao.findById(exportList.get(i));

I am getting the following exception

DEBUG org.hibernate.util.JDBCExceptionReporter - could not load an entity: [com.abc.xyz.datapersistence.model.Deposit#{ID=21}] [select deposit0_.id as id17_0_, deposit0_.customer_id as customer2_17_0_, deposit0_.customer_name as customer3_17_0_, deposit0_.account_id as account4_17_0_, deposit0_.account_nbr as account5_17_0_, deposit0_.control_balance as control6_17_0_, deposit0_.review_flag as review7_17_0_, deposit0_.reviewer_Id as reviewer8_17_0_, deposit0_.create_ts as create9_17_0_, deposit0_.transfer_ts as transfer10_17_0_, deposit0_.abort_ts as abort11_17_0_, deposit0_.submit_ts as submit12_17_0_, deposit0_.posting_date as posting13_17_0_, deposit0_.time_limit as time14_17_0_, deposit0_.status_id as status15_17_0_, deposit0_.item_limit as item16_17_0_, deposit0_.users_cg_id as users17_17_0_, deposit0_.session_token as session18_17_0_, deposit0_.session_key as session19_17_0_, deposit0_.account_Name as account20_17_0_, deposit0_.is_ach_opt_out as is21_17_0_, deposit0_.cg_deposit_id as cg22_17_0_, deposit0_.workflow_id as workflow23_17_0_, deposit0_.suspended_ts as suspended24_17_0_, deposit0_.is_export as is25_17_0_ from cc_deposit deposit0_ where deposit0_.id=?]
java.sql.SQLException: Missing IN or OUT parameter at index:: 1
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1681)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3280)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
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.loadEntity(Loader.java:1785)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:869)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:806)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:799)
at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:470)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:464)
at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:458)
at com.netdeposit.webclient.datapersistence.dao.hibernate.GenericHibernateDAO.findById(GenericHibernateDAO.java:82)
at com.netdeposit.webclient.service.impl.QBXMLReportGen.generateReport(QBXMLReportGen.java:141)
at com.netdeposit.webclient.service.impl.ExportServiceImpl.generateReport(ExportServiceImpl.java:183)
at com.netdeposit.webclient.junit.testcases.ExportTestCase.testGenerateReport(ExportTestCase.java:116)
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 junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:76)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
67004 [main] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 17041, SQLState: null
67004 [main] ERROR org.hibernate.util.JDBCExceptionReporter - Missing IN or OUT parameter at index:: 1
67004 [main] INFO org.hibernate.event.def.DefaultLoadEventListener - Error performing load command
org.hibernate.exception.GenericJDBCException: could not load an entity: [com.netdeposit.webclient.datapersistence.model.Deposit#{ID=21}]
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.loadEntity(Loader.java:1799)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:869)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:806)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:799)
at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:470)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:464)
at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:458)
at com.netdeposit.webclient.datapersistence.dao.hibernate.GenericHibernateDAO.findById(GenericHibernateDAO.java:82)
at com.netdeposit.webclient.service.impl.QBXMLReportGen.generateReport(QBXMLReportGen.java:141)
at com.netdeposit.webclient.service.impl.ExportServiceImpl.generateReport(ExportServiceImpl.java:183)
at com.netdeposit.webclient.junit.testcases.ExportTestCase.testGenerateReport(ExportTestCase.java:116)
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 junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:76)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.sql.SQLException: Missing IN or OUT parameter at index:: 1
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1681)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3280)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
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.loadEntity(Loader.java:1785)
... 39 more
67019 [main] DEBUG org.hibernate.jdbc.JDBCContext - after autocommit
67019 [main] DEBUG org.hibernate.jdbc.ConnectionManager - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
67019 [main] DEBUG org.hibernate.impl.SessionImpl - after transaction completion

and this at the end of the logs

DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'Sybase' to allow for resolving potential circular references
67347 [main] DEBUG org.springframework.beans.TypeConverterDelegate - Converting String to [class [Ljava.lang.String;] using property editor [org.springframework.beans.propertyeditors.StringArrayPropertyEditor@886c40]
67347 [main] DEBUG org.springframework.beans.TypeConverterDelegate - Converting String to [class [Ljava.lang.String;] using property editor [org.springframework.beans.propertyeditors.StringArrayPropertyEditor@886c40]
67347 [main] DEBUG org.springframework.beans.TypeConverterDelegate - Converting String to [class [Ljava.lang.String;] using property editor [org.springframework.beans.propertyeditors.StringArrayPropertyEditor@886c40]
67347 [main] INFO org.springframework.jdbc.support.SQLErrorCodesFactory - SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
67347 [main] DEBUG org.springframework.jdbc.support.SQLErrorCodesFactory - Looking up default SQLErrorCodes for DataSource [org.apache.commons.dbcp.BasicDataSource@120a9d6]
67363 [main] DEBUG org.springframework.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource
67394 [main] DEBUG org.springframework.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource
67394 [main] DEBUG org.springframework.jdbc.support.SQLErrorCodesFactory - Database product name cached for DataSource [org.apache.commons.dbcp.BasicDataSource@120a9d6]: name is 'Oracle'
67394 [main] DEBUG org.springframework.jdbc.support.SQLErrorCodesFactory - SQL error codes for 'Oracle' found
67394 [main] DEBUG org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator - Unable to translate SQLException with Error code '17041', will now try the fallback translator
67394 [main] DEBUG org.springframework.orm.hibernate3.HibernateTemplate - Not closing pre-bound Hibernate Session after HibernateTemplate
513501 [main] ERROR com.netdeposit.webclient.service.impl.QBXMLReportGen - 90171:Method Status:Method Error [error=Hibernate operation: could not load an entity: [com.netdeposit.webclient.datapersistence.model.Deposit#{ID=21}]; uncategorized SQLException for SQL [select deposit0_.id as id17_0_, deposit0_.customer_id as customer2_17_0_, deposit0_.customer_name as customer3_17_0_, deposit0_.account_id as account4_17_0_, deposit0_.account_nbr as account5_17_0_, deposit0_.control_balance as control6_17_0_, deposit0_.review_flag as review7_17_0_, deposit0_.reviewer_Id as reviewer8_17_0_, deposit0_.create_ts as create9_17_0_, deposit0_.transfer_ts as transfer10_17_0_, deposit0_.abort_ts as abort11_17_0_, deposit0_.submit_ts as submit12_17_0_, deposit0_.posting_date as posting13_17_0_, deposit0_.time_limit as time14_17_0_, deposit0_.status_id as status15_17_0_, deposit0_.item_limit as item16_17_0_, deposit0_.users_cg_id as users17_17_0_, deposit0_.session_token as session18_17_0_, deposit0_.session_key as session19_17_0_, deposit0_.account_Name as account20_17_0_, deposit0_.is_ach_opt_out as is21_17_0_, deposit0_.cg_deposit_id as cg22_17_0_, deposit0_.workflow_id as workflow23_17_0_, deposit0_.suspended_ts as suspended24_17_0_, deposit0_.is_export as is25_17_0_ from cc_deposit deposit0_ where deposit0_.id=?]; SQL state [null]; error code [17041]; Missing IN or OUT parameter at index:: 1; nested exception is java.sql.SQLException: Missing IN or OUT parameter at index:: 1; method=generateReport]

I am clueless any help will be appreciated
Thanks in advance
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30749
    
156

This sounds like a Hibernate question. Moving to our ORM forum.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10201
    
166

depositDao.findById(exportList.get(i));


Does, exportList.get(i) by any chance return a NULL?


[My Blog] [JavaRanch Journal]
zamir arif
Greenhorn

Joined: Nov 21, 2008
Posts: 5
Originally posted by Jaikiran Pai:


Does, exportList.get(i) by any chance return a NULL?


Hi JaiKiran,

Thanks for replying. I have checked exportList.get(i). It is not returning a null.
ntumba lobo
Ranch Hand

Joined: Oct 21, 2008
Posts: 180
what is the return then of exportList.get(i) ?
Anyway it seems that the return cannot be used in your request as an id


SCJP 5 , SCWCD 5, SCEA 5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not closing pre-bound Hibernate Session after HibernateTemplate