Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0.1
Mapping documents:
1st Attempt
Code:
<sql-query name="getSecurityInfo" callable="true">
<return alias="aqlp" class="com.nationwide.ag.model.AQLP">
<return-property name="objectId" column="id"/>
<return-property name="returnValue" column="IsAPAdmin"/>
</return>
{ ? = call upAPGetSecurityInfo() }
</sql-query>
2nd AttemptCode:
<sql-query name="getSecurityInfo" callable="true">
<return alias="aqlp" class="com.nationwide.ag.model.AQLP">
<return-property name="objectId" column="id"/>
<return-property name="returnValue" column="IsAPAdmin"/>
</return>
{ ? = call upAPGetSecurityInfo(?) }
</sql-query>
Code between sessionFactory.openSession() and session.close():1st and 2nd Attempts - see stack traces belowCode:
results = getHibernateTemplate().findByNamedQuery(storedProcName, userId);
I have also tried the following code
Code:
results = getHibernateTemplate().findByNamedQueryAndNamedParam(storedProcName, "@NetworkId", userId);
but get the java.lang.IllegalArgumentException "Parameter @NetworkId does not exist as a named parameter in [<queryString>]".
The queryString I have attempted are:
- { ? = call upAPGetSecurityInfo() }
- { ? = call upAPGetSecurityInfo(?) }
- { ? = call upAPGetSecurityInfo(@NetworkId) }
Full stack trace of any exception that occurs:
1st Attempt
0 WARN [main] util.JDBCExceptionReporter - SQL Error: 201, SQLState: HY000
0 ERROR [main] util.JDBCExceptionReporter - [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]
Procedure 'upAPGetSecurityInfo' expects parameter '@NetworkId', which was not supplied.
10 ERROR [main] hibernate.BaseHibernateDAO - Failure to retrieve by stored procedure getSecurityInfo because of the following database problem: (Hibernate operation): encountered SQLException [[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Procedure 'upAPGetSecurityInfo' expects parameter '@NetworkId', which was not supplied.]; nested exception is java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Procedure 'upAPGetSecurityInfo' expects parameter '@NetworkId', which was not supplied.
org.springframework.jdbc.UncategorizedSQLException: (Hibernate operation): encountered SQLException [[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Procedure 'upAPGetSecurityInfo' expects parameter '@NetworkId', which was not supplied.]; nested exception is java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Procedure 'upAPGetSecurityInfo' expects parameter '@NetworkId', which was not supplied.
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Procedure 'upAPGetSecurityInfo' expects parameter '@NetworkId', which was not supplied.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.executeInternal(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.execute(Unknown Source)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:168)
at org.hibernate.dialect.SybaseDialect.getResultSet(SybaseDialect.java:140)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:126)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1202)
at org.hibernate.loader.Loader.doQuery(Loader.java:368)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:208)
at org.hibernate.loader.Loader.doList(Loader.java:1522)
at org.hibernate.loader.Loader.list(Loader.java:1505)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:103)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1343)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:151)
at org.springframework.orm.hibernate3.HibernateTemplate$32.doInHibernate(HibernateTemplate.java:812)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:310)
at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQuery(HibernateTemplate.java:803)
at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQuery(HibernateTemplate.java:799)
at com.nationwide.ag.persistence.dao.hibernate.BaseHibernateDAO.retrieveByStoredProc(BaseHibernateDAO.java:104)
at com.nationwide.ag.persistence.dao.hibernate.DbaiDAOImpl.retrieveSecurityInfo(DbaiDAOImpl.java:43)
at com.nationwide.ag.persistence.dao.hibernate.DbaiDAOImplTest.testRetrieveSecurityInfo(DbaiDAOImplTest.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
at java.lang.reflect.Method.invoke(Method.java:391)
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 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:436)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:311)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
2nd Attempt
0 WARN [main] util.JDBCExceptionReporter - SQL Error: 0, SQLState: 07009
0 ERROR [main] util.JDBCExceptionReporter - [Microsoft][SQLServer 2000 Driver for JDBC]
Invalid parameter binding(s).
0 ERROR [main] hibernate.BaseHibernateDAO - Failure to retrieve by stored procedure getSecurityInfo because of the following database problem: Bad SQL grammar [] in task 'Hibernate operation'; nested exception is java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid parameter binding(s).
org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [] in task 'Hibernate operation'; nested exception is java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid parameter binding(s).
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid parameter binding(s).
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.validateParameters(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.validateParameters(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.preImplExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.executeInternal(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.execute(Unknown Source)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:168)
at org.hibernate.dialect.SybaseDialect.getResultSet(SybaseDialect.java:140)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:126)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1202)
at org.hibernate.loader.Loader.doQuery(Loader.java:368)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:208)
at org.hibernate.loader.Loader.doList(Loader.java:1522)
at org.hibernate.loader.Loader.list(Loader.java:1505)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:103)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1343)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:151)
at org.springframework.orm.hibernate3.HibernateTemplate$32.doInHibernate(HibernateTemplate.java:812)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:310)
at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQuery(HibernateTemplate.java:803)
at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQuery(HibernateTemplate.java:799)
at com.nationwide.ag.persistence.dao.hibernate.BaseHibernateDAO.retrieveByStoredProc(BaseHibernateDAO.java:104)
at com.nationwide.ag.persistence.dao.hibernate.DbaiDAOImpl.retrieveSecurityInfo(DbaiDAOImpl.java:43)
at com.nationwide.ag.persistence.dao.hibernate.DbaiDAOImplTest.testRetrieveSecurityInfo(DbaiDAOImplTest.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
at java.lang.reflect.Method.invoke(Method.java:391)
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 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:436)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:311)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Name and version of the database you are using:
MS SQLServer 2000
The generated SQL (show_sql=true):
1st Attempt
Hibernate: { ? = call upAPGetSecurityInfo() }
2nd Attempt
Hibernate: { ? = call upAPGetSecurityInfo(?) }
Debug level Hibernate log excerpt: