db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "coluf" <co...@hotmail.com>
Subject Bad code generation with Java dates?
Date Wed, 25 Feb 2004 04:51:19 GMT
Hi

I am having trouble with Torque generating an exception on a '.doSelect()' on a Torque Peer
object.  It appears the cause to be Torque
generating the wrong code.  I start by creating a Criteria object and add to it that a column
'HITDATE' should equal a given date. On 
calling the 'doSelect()' method, I see that Torque generated a 'timestamp' type instead of
a 'date' type even though the schema specified 
the column to be of type 'DATE'.  

I tried running the query with editting the query so instead of 'HitSummary.HITDATE={ts '2004-02-10
14:23:10.1'}', I have 
'HitSummary.HITDATE='2004-02-10''.  It works.

To try to force Torque to generate a 'Date' instead of a 'Timestamp', I have tried normalising
the date by explicitly setting the 
time of 'hitDate' to 0:0:0.  It did not work as I got 'HitSummary.HITDATE={ts '2004-02-10
14:23:10.1'}'.  A 'TimeStamp' type 
and not a 'Date' type.

How else could I force the criteria to generate a Date instead of a Timestamp?  Any other
thoughts?

I am using SapDb and I have confirmed the column type in the table HitSummary' to be 'Date'.
 I have included code extracts below.


Any suggests appreciated.

Chris O.

__________________________________________________________________________
Mycode

Calendar calendar = new GregorianCalendar();
calendar.setTime(ssv.getHitDateTime());
Date hitDate = (new GregorianCalendar(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
calendar.get(Calendar.DATE)).getTime());

// Calculate timeslot value
timeSlotIndex = indexCalculator.calculateIndex(ssv.getHitDateTime());

// Locate hitSummaryByDateRoute
criteria = new Criteria();
criteria.add(HitsummaryPeer.HITDATE, hitDate);
criteria.add(HitsummaryPeer.AIRLINECODE, ssv.getAirlineCode());
criteria.add(HitsummaryPeer.TIMESLOT, timeSlotIndex);
criteria.add(HitsummaryPeer.AIRPORTFROM, ssv.getAirportFrom());
criteria.add(HitsummaryPeer.AIRPORTTO, ssv.getAirportTo());

__________________________________________________________________________
Generated code (taken from my log)

SELECT HitSummary.AIRLINECODE, HitSummary.HITDATE, HitSummary.TIMESLOT, HitSummary.AIRPORTFROM,
HitSummary.AIRPORTTO, HitSummary.NUMPNRS, HitSummary.NUMFLIGHTS, HitSummary.NUMSEARCHES, HitSummary.NUMFIRSTCLASS,
HitSummary.NUMBUSINESSCLASS, HitSummary.NUMECONOMYCLASS, HitSummary.NUMADULTS, HitSummary.NUMYOUTHS,
HitSummary.NUMCHILDREN, HitSummary.NUMINFANTS, HitSummary.NUMSENIORS FROM HitSummary WHERE
HitSummary.TIMESLOT=42 AND HitSummary.AIRPORTFROM='DUB' AND HitSummary.AIRLINECODE='BT' AND
HitSummary.AIRPORTTO='RIX' AND HitSummary.HITDATE={ts '2004-02-10 00:00:00.0'}

_________________________________________________________________________
Extract from Torque schema

   <table name="HitSummary" description="Summary of hits by airline/date/route">
      <column
         name="AirlineCode"
         required="true"
         primaryKey="true"
         type="VARCHAR"
         size="2"
         description="Airline code"/>
      <foreign-key foreignTable="CodeAirline">
         <reference
            local="AirlineCode"
            foreign="AirlineCode"/>
      </foreign-key>
      <column
         name="HitDate"
         required="true"
         primaryKey="true"
         type="DATE"
         description="Date of route hit"/>
      <column
         name="TimeSlot"
         required="true"
         primaryKey="true"
         type="INTEGER"
         description="Timeslot of route hit"/>


_________________________________________________________________________
Extract from the runtime logs showing the exception

2004-02-25 15:26:26,750 INFO [consumer0] - Criteria: Criteria:: HitSummary.TIMESLOT<=>HitSummary.TIMESLOT=42:
 HitSummary.AIRPORTFROM<=>HitSummary.AIRPORTFROM='DUB':  HitSummary.AIRLINECODE<=>HitSummary.AIRLINECODE='BT':
 HitSummary.AIRPORTTO<=>HitSummary.AIRPORTTO='RIX':  HitSummary.HITDATE<=>HitSummary.HITDATE={ts
'3904-02-01 00:00:00.0'}:  
Current Query SQL (may not be complete or applicable): SELECT  FROM HitSummary WHERE HitSummary.TIMESLOT=42
AND HitSummary.AIRPORTFROM='DUB' AND HitSummary.AIRLINECODE='BT' AND HitSummary.AIRPORTTO='RIX'
AND HitSummary.HITDATE={ts '3904-02-01 00:00:00.0'}
2004-02-25 15:26:26,812 ERROR [consumer0] - SearchStatsDispatcher
com.sap.dbtech.jdbc.exceptions.DatabaseException: [-9111] (at 551): System error: Move error
 at com.sap.dbtech.jdbc.packet.ReplyPacket.createException(ReplyPacket.java:69)
 at com.sap.dbtech.jdbc.ConnectionSapDB.throwSQLError(ConnectionSapDB.java:763)
 at com.sap.dbtech.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:429)
 at com.sap.dbtech.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:320)
 at com.sap.dbtech.jdbc.StatementSapDB.sendCommand(StatementSapDB.java:680)
 at com.sap.dbtech.jdbc.StatementSapDB.sendSQL(StatementSapDB.java:723)
 at com.sap.dbtech.jdbc.StatementSapDB.execute(StatementSapDB.java:219)
 at com.sap.dbtech.jdbc.StatementSapDB.executeQuery(StatementSapDB.java:350)
 at com.workingdogs.village.QueryDataSet.<init>(Unknown Source)
 at org.apache.torque.util.BasePeer.executeQuery(BasePeer.java:1539)
 at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1391)
 at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1368)
 at au.com.eb2.torque.reports.data.BaseHitsummaryPeer.doSelectVillageRecords(BaseHitsummaryPeer.java:432)
 at au.com.eb2.torque.reports.data.BaseHitsummaryPeer.doSelectVillageRecords(BaseHitsummaryPeer.java:400)
 at au.com.eb2.torque.reports.data.BaseHitsummaryPeer.doSelect(BaseHitsummaryPeer.java:369)
 at au.com.eb2.customerservice.bullant.SearchStatsDispatcher.dispatch(SearchStatsDispatcher.java:75)
 at au.com.eb2.customerservice.server.CustomerServiceConsumer.dispatchMessage(CustomerServiceConsumer.java:91)
 at au.com.eb2.customerservice.server.CustomerServiceConsumer.runTask(CustomerServiceConsumer.java:70)
 at au.com.eb2.shared.util.Task$ThreadHelper.run(Task.java:77)
 at java.lang.Thread.run(Thread.java:536)
rethrown as 
org.apache.torque.TorqueException: [-9111] (at 551): System error: Move error
 at org.apache.torque.util.BasePeer.throwTorqueException(BasePeer.java:236)
 at org.apache.torque.util.BasePeer.executeQuery(BasePeer.java:1550)
 at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1391)
 at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1368)
 at au.com.eb2.torque.reports.data.BaseHitsummaryPeer.doSelectVillageRecords(BaseHitsummaryPeer.java:432)
 at au.com.eb2.torque.reports.data.BaseHitsummaryPeer.doSelectVillageRecords(BaseHitsummaryPeer.java:400)
 at au.com.eb2.torque.reports.data.BaseHitsummaryPeer.doSelect(BaseHitsummaryPeer.java:369)
 at au.com.eb2.customerservice.bullant.SearchStatsDispatcher.dispatch(SearchStatsDispatcher.java:75)
 at au.com.eb2.customerservice.server.CustomerServiceConsumer.dispatchMessage(CustomerServiceConsumer.java:91)
 at au.com.eb2.customerservice.server.CustomerServiceConsumer.runTask(CustomerServiceConsumer.java:70)
 at au.com.eb2.shared.util.Task$ThreadHelper.run(Task.java:77)
 at java.lang.Thread.run(Thread.java:536)
Caused by: com.sap.dbtech.jdbc.exceptions.DatabaseException: [-9111] (at 551): System error:
Move error
 at com.sap.dbtech.jdbc.packet.ReplyPacket.createException(ReplyPacket.java:69)
 at com.sap.dbtech.jdbc.ConnectionSapDB.throwSQLError(ConnectionSapDB.java:763)
 at com.sap.dbtech.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:429)
 at com.sap.dbtech.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:320)
 at com.sap.dbtech.jdbc.StatementSapDB.sendCommand(StatementSapDB.java:680)
 at com.sap.dbtech.jdbc.StatementSapDB.sendSQL(StatementSapDB.java:723)
 at com.sap.dbtech.jdbc.StatementSapDB.execute(StatementSapDB.java:219)
 at com.sap.dbtech.jdbc.StatementSapDB.executeQuery(StatementSapDB.java:350)
 at com.workingdogs.village.QueryDataSet.<init>(Unknown Source)
 at org.apache.torque.util.BasePeer.executeQuery(BasePeer.java:1539)
 ... 10 more
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message