Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Could not locate named parameter [1]

843859May 16 2008 — edited Apr 2 2009
Hi all,

I am having an issue with this one table, session. I use it to store session information:
testFindBySessionId(com.walterjwhite.manager.impl.SessionManagerIntegerationTest)  Time elapsed: 5.226 sec  <<< ERROR!
org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.QueryParameterException: could not locate named parameter [1]; nested exception is java.lang.IllegalArgumentException: org.hibernate.QueryParameterException: could not locate named parameter [1]
Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryParameterException: could not locate named parameter [1]
	at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:185)
	at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:240)
	at org.springframework.orm.jpa.JpaTemplate$11.doInJpa(JpaTemplate.java:343)
	at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:191)
	at org.springframework.orm.jpa.JpaTemplate.executeFind(JpaTemplate.java:158)
	at org.springframework.orm.jpa.JpaTemplate.findByNamedQuery(JpaTemplate.java:338)
	at com.walterjwhite.persistence.jpa.GenericJpaDao.executeFinder(GenericJpaDao.java:85)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
	at com.walterjwhite.aspect.DataAccessFinder.invoke(DataAccessFinder.java:65)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
	at $Proxy30.executeFinder(Unknown Source)
	at com.walterjwhite.aspect.DataAccessFinder.invoke(DataAccessFinder.java:44)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
	at $Proxy38.findBySessionId(Unknown Source)
	at com.walterjwhite.manager.impl.SessionManagerImpl.findBySessionId(SessionManagerImpl.java:40)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
	at $Proxy40.findBySessionId(Unknown Source)
	at com.walterjwhite.manager.impl.SessionManagerIntegerationTest.testFindBySessionId(SessionManagerIntegerationTest.java:27)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	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.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
	at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:616)
	at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
	at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
Caused by: org.hibernate.QueryParameterException: could not locate named parameter [1]
	at org.hibernate.engine.query.ParameterMetadata.getNamedParameterDescriptor(ParameterMetadata.java:75)
	at org.hibernate.engine.query.ParameterMetadata.getNamedParameterExpectedType(ParameterMetadata.java:81)
	at org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:413)
	at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:383)
	at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:180)
	... 54 more
I can insert data properly into this table, but I cannot actually get a session back if I try findBySessionId. I am getting the exception reporting that it could not found named parameter [1]. I have checked for typos numerous times and compared it with my other classes to no avail. I realize session is a reserved sql99 keyword, but does that matter here?
@NamedQuery(name = "Session.findBySessionId", query = "SELECT s FROM Session s WHERE s.sessionId = :sessionId")
All of my other table/domain classes work fine, this is the only exception so that is why I'm thinking I have a name conflict, but the same is true. I also tried accessing this class as com.walterjwhite.domain.Session and get the same thing.

Any help is much appreciated.


Thanks,
Walter
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 30 2009
Added on May 16 2008
3 comments
11,594 views