Hibernate version:
3.2.4 sp1 (packaged with JBoss 4.2.2 GA)
Mapping documents:
Code:
<hibernate-mapping>
<class name="com.orci.websol.gis.navteq.summary.gen.Route" table="routes" >
<composite-id name="id" class="com.orci.websol.gis.navteq.summary.gen.RouteId">
<key-property name="name" type="java.lang.String" column="route_name" length="255" />
<key-property name="type" type="java.lang.Integer column="route_type" />
<key-property name="jurisdiction" type="com.orci.websol.gis.navteq.summary.gen.Jurisdiction" column="juris_code" />
</composite-id>
<property name="minX" type="java.lang.Double" column="min_x" not-null="true" />
<property name="minY" type="java.lang.Double" column="min_y" not-null="true" />
<property name="maxX" type="java.lang.Double" column="max_x" not-null="true" />
<property name="maxY" type="java.lang.Double" column="max_y" not-null="true" />
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="com.orci.websol.gis.navteq.summary.gen.Jurisdiction" table="jurisdictions" >
<id name="id" type="java.lang.Integer" column="juris_code" />
<property name="name" type="java.lang.String" column="juris_name" not-null="true" length="255" unique="true" />
<property name="state" type="java.lang.String" column="juris_state" not-null="true" length="2" />
<property name="type" type="java.lang.String" column="juris_type" not-null="true" length="16" />
<property name="minX" type="java.lang.Double" column="min_x" not-null="true" />
<property name="minY" type="java.lang.Double" column="min_y" not-null="true" />
<property name="maxX" type="java.lang.Double" column="max_x" not-null="true" />
<property name="maxY" type="java.lang.Double" column="max_y" not-null="true" />
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():(simplified)
Code:
Query q = session.createQuery("from com.orci.websol.gis.navteq.summary.gen.Route where id.jurisdiction.id = :jurisdictionId and (routeType = :routeType0 or routeType = :routeType1)");
q.setInteger("jurisdictionId", 21002629);
q.setInteger("routeType0", 2);
q.setInteger("routeType1", 3);
q.list();
Full stack trace of any exception that occurs:Code:
org.hibernate.exception.DataException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2223)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at com.orci.websol.gis.navteq.summary.RouteServices.getRoutesInJuris(RouteServices.java:57)
at com.orci.datagateway.react.geos.navteq.RouteChoiceList.getUpdatedChoices(RouteChoiceList.java:55)
at com.orci.datagateway.react.wicket.DelegatingListChoiceModel.getUpdatedChoices(DelegatingListChoiceModel.java:33)
at com.orci.datagateway.react.component.AbstractChoiceList.onStateChange(AbstractChoiceList.java:44)
at com.orci.datagateway.react.state.NoLoopStateChangeManager.change(NoLoopStateChangeManager.java:88)
at com.orci.datagateway.react.component.AccessibleComponentLogic.userInput(AccessibleComponentLogic.java:48)
at com.orci.datagateway.react.wicket.LogicComponentInitializer$1.onUpdate(LogicComponentInitializer.java:43)
at org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior.onEvent(AjaxFormComponentUpdatingBehavior.java:145)
at org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:166)
at org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:298)
at org.apache.wicket.request.target.component.listener.BehaviorRequestTarget.processEvents(BehaviorRequestTarget.java:100)
at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:91)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1188)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1265)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1366)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:499)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:387)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:199)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.orci.datagateway.filters.WebTransaction.doFilter(WebTransaction.java:49)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:856)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:566)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1508)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.postgresql.util.PSQLException: No value specified for parameter 4.
at org.postgresql.core.v3.SimpleParameterList.checkAllParametersSet(SimpleParameterList.java:146)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:182)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:351)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:255)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
... 46 more
Name and version of the database you are using:PostgreSQL 8.2
The generated SQL (show_sql=true):Code:
select route0_.route_name as route1_2_, route0_.route_type as route2_2_, route0_.juris_code as juris3_2_, route0_.min_x as min4_2_, route0_.min_y as min5_2_, route0_.max_x as max6_2_, route0_.max_y as max7_2_ from routes route0_ where route0_.route_name=? and route0_.route_type=? and route0_.juris_code=? and (routeType=? or routeType=?)
Can't figure out what I'm doing wrong here... maybe something will stand out to someone else. I'm trying to execute a fairly straight forward query but its failing with the exception above, and the SQL generated doesn't seem quite right. For some reason it's trying to use the route_name column as a parameter but my HQL doesn't mention that attribute at all. route_name is part of the key though, so I don't know if its related to that in some way. Using the debugger I placed a breakpoint on the q.list() line and checked the query's named attributes and they look correct:
Code:
{routeType0=2, routeType1=3, jurisdictionId=21002629}
Any ideas on why the generated SQL has 4 parameters if my HQL only has 3? Is something wrong with my mappings?