These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: HQL-query throwing exception after upgrade to 3.2.5
PostPosted: Fri Jan 11, 2008 5:59 am 
Newbie

Joined: Fri Jan 11, 2008 5:38 am
Posts: 1
Hi everbody,

I just recently upgraded to the latest version of Hibernate (3.2.5) and all my tests (around 250) ran through without any major problem. I just came across one issue which robbed me a whole day, but I wasn't able to find a solution. It has to do with a certain HQL-query (see below) that worked just fine before the upgrade but leads to an exception now. In my eyes, which doesn't mean anything of course, the query is correct (nothing special about it, really). After slight changes to the syntax (not joining the "aircraft" but resolving the ID by writing fp.aircraft.id in the select-clause) the exception disappeared but the query would not return any results anymore. Please see the details below, I hope someone had a similar problem and might be able to give me a hint where to look.

Hibernate version:
3.2.5-ga

Mapping documents:
The mapping for the FlightPlan object:
Code:
<!-- ****************************************************************** -->
   <!-- FLIGHT PLAN -->

   <class name="FlightPlan" table="as_flight_plans">
   
      <id name="id" column="id_flight_plan">
         <generator class="identity"/>
      </id>
      
      <many-to-one name="flight" column="id_flight" fetch="join"/>
      <many-to-one name="aircraft" column="id_aircraft" fetch="join"/>
      
      <property name="day" column="n_day"/>
      <property name="dayUTC" column="n_day_utc"/>
      <property name="duration1" column="n_duration_1"/>
      <property name="economy1" column="n_economy_1"/>
      <property name="business1" column="n_business_1"/>
      <property name="first1" column="n_first_1"/>
      <property name="freight1" column="n_freight_1"/>
      <property name="fuel1" column="n_fuel_1"/>
      <property name="duration2" column="n_duration_2"/>
      <property name="economy2" column="n_economy_2"/>
      <property name="business2" column="n_business_2"/>
      <property name="first2" column="n_first_2"/>
      <property name="freight2" column="n_freight_2"/>
      <property name="fuel2" column="n_fuel_2"/>
   
   </class>      


The query that causes the trouble:
Code:
<query name="FlightUpdate.FICR.regular"><![CDATA[
   
      select new de.airlinesim.model.report.FlightUpdateFICRRow
      (
         f.id,
         f.locked,
         a.id,
         fp.dayUTC,
         case when f.via is null then false else true end,
         f.originDepartureUTC,
         f.viaDepartureUTC,
         fp.duration1,
         fp.economy1,
         fp.business1,
         fp.first1,
         fp.freight1,
         fp.fuel1,
         fp.duration2,
         fp.economy2,
         fp.business2,
         fp.first2,
         fp.freight2,
         fp.fuel2
      )
      from
         FlightPlan fp
         join fp.flight f
         join fp.aircraft a
      where
         (fp.dayUTC * 1440 + f.originDepartureUTC) >= :startMinute
      and
         (fp.dayUTC * 1440 + f.originDepartureUTC) < :endMinute
   
   ]]>
   </query>


Code between sessionFactory.openSession() and session.close():
There's too much code to post it all really, but this is the part executing the query (nothing wrong with it I think):
Code:
List required = getSession() //
         .getNamedQuery(q) //
         .setShort("startMinute", startMinute) //$NON-NLS-1$
         .setShort("endMinute", endMinute) //$NON-NLS-1$
         .list();

"startMinute" and "endMinute" being short-values and q the name of the named query. If you have an idea and need any more code fragments to answer my question, please let me know and I'll post the required parts/objects/whatever.

Full stack trace of any exception that occurs:
Code:
17:27:50,887 DEBUG JDBCExceptionReporter:69 - could not execute query [select flight1_.id_flight as col_0_0_, flight1_.b_locked as col_1_0_, aircraft2_.id_aircraft as col_2_0_, flightplan0_.n_day_utc as col_3_0_, case when flight1_.id_via is null then 0 else 1 end as col_4_0_, flight1_.n_origin_departure_utc as col_5_0_, flight1_.n_via_departure_utc as col_6_0_, flightplan0_.n_duration_1 as col_7_0_, flightplan0_.n_economy_1 as col_8_0_, flightplan0_.n_business_1 as col_9_0_, flightplan0_.n_first_1 as col_10_0_, flightplan0_.n_freight_1 as col_11_0_, flightplan0_.n_fuel_1 as col_12_0_, flightplan0_.n_duration_2 as col_13_0_, flightplan0_.n_economy_2 as col_14_0_, flightplan0_.n_business_2 as col_15_0_, flightplan0_.n_first_2 as col_16_0_, flightplan0_.n_freight_2 as col_17_0_, flightplan0_.n_fuel_2 as col_18_0_ from as_flight_plans flightplan0_ inner join as_flights flight1_ on flightplan0_.id_flight=flight1_.id_flight, as_offices office3_ inner join as_aircrafts aircraft2_ on flightplan0_.id_aircraft=aircraft2_.id_aircraft where flight1_.id_via=office3_.id_office and flightplan0_.n_day_utc*1440+flight1_.n_origin_departure_utc>=? and flightplan0_.n_day_utc*1440+flight1_.n_origin_departure_utc<?]
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'flightplan0_.id_aircraft' in 'on clause'
   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
   at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
   at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
   at com.mysql.jdbc.Connection.execSQL(Connection.java:3176)
   at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1153)
   at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1266)
   at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
   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)
   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)


Name and version of the database you are using:
MySQL 5.0.27-community-nt

The generated SQL (show_sql=true):
Code:
17:27:50,887 DEBUG SQL:401 - select flight1_.id_flight as col_0_0_, flight1_.b_locked as col_1_0_, aircraft2_.id_aircraft as col_2_0_, flightplan0_.n_day_utc as col_3_0_, case when flight1_.id_via is null then 0 else 1 end as col_4_0_, flight1_.n_origin_departure_utc as col_5_0_, flight1_.n_via_departure_utc as col_6_0_, flightplan0_.n_duration_1 as col_7_0_, flightplan0_.n_economy_1 as col_8_0_, flightplan0_.n_business_1 as col_9_0_, flightplan0_.n_first_1 as col_10_0_, flightplan0_.n_freight_1 as col_11_0_, flightplan0_.n_fuel_1 as col_12_0_, flightplan0_.n_duration_2 as col_13_0_, flightplan0_.n_economy_2 as col_14_0_, flightplan0_.n_business_2 as col_15_0_, flightplan0_.n_first_2 as col_16_0_, flightplan0_.n_freight_2 as col_17_0_, flightplan0_.n_fuel_2 as col_18_0_ from as_flight_plans flightplan0_ inner join as_flights flight1_ on flightplan0_.id_flight=flight1_.id_flight, as_offices office3_ inner join as_aircrafts aircraft2_ on flightplan0_.id_aircraft=aircraft2_.id_aircraft where flight1_.id_via=office3_.id_office and flightplan0_.n_day_utc*1440+flight1_.n_origin_departure_utc>=? and flightplan0_.n_day_utc*1440+flight1_.n_origin_departure_utc<?


I appreciate any help. Thank you a lot.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.