Hibernate version: 3.2.0GA
Mapping documents: None, annotations being used
Full stack trace of any exception that occurs:
Code:
Caused by: javax.ejb.EJBException: java.lang.IllegalArgumentException: org.hibernate.QueryParameterException: could not locate named parameter [y]
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:181)
at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:79)
at $Proxy175.testQueryData(Unknown Source)
at com.test.spatial.mbean.GeoDataTester.queryData(GeoDataTester.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
... 29 more
Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryParameterException: could not locate named parameter [y]
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:177)
at com.test.spatial.beans.GeoTestBean.queryGeoItems(GeoTestBean.java:68)
at com.test.spatial.beans.GeoTestBean.testQueryData(GeoTestBean.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
... 50 more
Caused by: org.hibernate.QueryParameterException: could not locate named parameter [y]
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:172)
... 65 more
Name and version of the database you are using: Postgresql 8.1.4
Hi, i am using PostGis in conjunction with Postgres in an EJB3 environment (using a User defined Type). The persisting works fine, the querying via a native query works fine so long as it is a query string with no parameters. The problems start to occur when adding some parameters to the query, but it only happens when parameters are added in a certain places in the query string.
The following query works:
Code:
// create the native query
Query nativeQuery = mEntityManager.createNativeQuery("SELECT * FROM table " +
"WHERE the_geom && Expand(GeomFromText('POINT(5 5)', -1), :distance) " +
"AND Distance(GeomFromText('POINT(5 5 )', -1), the_geom) < :distance", geoItem.class);
// set the parameters
nativeQuery.setParameter("distance", pDistance);
But the following one causes the stack trace above
Code:
// create the native query
Query nativeQuery = mEntityManager.createNativeQuery("SELECT * FROM table " +
"WHERE the_geom && Expand(GeomFromText('POINT(5 5)', -1), :distance) " +
"AND Distance(GeomFromText('POINT(5 :y )', -1), the_geom) < :distance", geoItem.class);
// set the parameters
nativeQuery.setParameter("distance", pDistance);
nativeQuery.setParameter("y", pPointY);
It appears to me that any parameter placed between the brackets of the POINT definition are never found !! But the distance paramter is found !!
In my opinion this is a bug. Should i enter a JIRA issue for it (it will take me a while to reduce it to a runnable test case)?
Cheers,
Andy