db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Quinton McCombs" <qmcco...@nequalsone.com>
Subject RE: addAscendingOrderBy problem
Date Wed, 18 Dec 2002 15:18:49 GMT
I ran into a problem with adding an order by when the database column
allowed null values.  Just for the sake of testing, make sure that there
are no nulls in the column that you are ordering by.  If this solves
your problem then we have another instance of a bug that I reported
under TRQS91.

I have not tested this for numeric columns.  However, if your javaType
for the table in question is set to primative, number columns will
return 0 instead of null anyway.

BTW - my database is Oracle.

> -----Original Message-----
> From: Prescott R. Balch [mailto:prescott@prescottbalch.org] 
> Sent: Wednesday, December 18, 2002 9:04 AM
> To: turbine-torque-dev@jakarta.apache.org
> Subject: addAscendingOrderBy problem
> 
> 
> 
> I've run this by the torque users list and everyone there who 
> has tried to help is stumped as much as I am.  One kind 
> torque user used the same schema, the same code, perhaps a 
> different db (postgresql vs mysql -- he didn't specify in his 
> response, but I'm confirming), and it worked just fine.  It 
> was suggested I post the problem to this list to see if 
> someone might be able to shed light on my problem.
> 
> The issue is that when I use the addAscendingOrderBy method 
> to add a character column to the orderBy clause, I get a 
> nullPointerException. When I use a numeric column, it works 
> fine.  I've included the code, the stack trace, the schema, 
> and relevant version info.
> 
> Any help is appreciated.
> 
> code snippet:
> 
>      vRuntypes = new ArrayList();
>      crit = new Criteria();
>      crit.add(RuntypePeer.RUNNERID,myRunner.getRunnerid());
>      crit.addAscendingOrderByColumn(RuntypePeer.RUNTYPE);
>      crit.addAscendingOrderByColumn(RuntypePeer.RUNTYPEID);
>      cat.debug("order by columns: " +
>      crit.getOrderByColumns().toString());
>      cat.debug("order by size: " + crit.getOrderByColumns().size());
>      cat.debug("crit: " + crit.toString());
>      try {
>          vRuntypes = (ArrayList)RuntypePeer.doSelect(crit);
> 	 } catch (TorqueException te) {
> 	     vRuntypes = null;
> 	         cat.error("Could not select runtypes: " +
>      te.toString());
>          te.printStackTrace();
> 	 }
> 
> 
> stack trace:
> 
> 2002-12-16 14:24:15,952 [AWT-EventQueue-0] DEBUG 
> org.yarl.swing.RunnerListFrame - creating RunHistoryFrame 
> 2002-12-16 14:24:15,982 [AWT-EventQueue-0] DEBUG 
> org.yarl.swing.YarlFrame - imageIcon = images/icon_runner.gif 
> 2002-12-16 14:24:15,982 [AWT-EventQueue-0] DEBUG 
> org.yarl.swing.RunHistoryFrame - 
> java.awt.Dimension[width=750,height=500]
> 2002-12-16 14:24:15,992 [AWT-EventQueue-0] DEBUG 
> org.yarl.swing.RunHistoryFrame - order by columns: 
> RunType.RUNTYPE ASCRunType.RUNTYPEID ASC 2002-12-16 
> 14:24:15,992 [AWT-EventQueue-0] DEBUG 
> org.yarl.swing.RunHistoryFrame - order by size: 2 2002-12-16 
> 14:24:15,992 [AWT-EventQueue-0] DEBUG 
> org.yarl.swing.RunHistoryFrame - crit: Criteria::
> RunType.RUNNERID<=>RunType.RUNNERID=1000:  
> Current Query SQL (may not be complete or applicable): 
> 2002-12-16 14:24:16,022 [AWT-EventQueue-0] ERROR 
> org.yarl.swing.RunHistoryFrame - Could not select runtypes: 
> org.apache.torque.TorqueException java.lang.NullPointerException
> 	at
> org.apache.torque.util.BasePeer.createQueryString(BasePeer.java:1168)
> 	at
> org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1260)
> 	at org.yarl.om.BaseRuntypePeer.doSelectVillageRecords(Unknown
> Source)
> 	at org.yarl.om.BaseRuntypePeer.doSelectVillageRecords(Unknown
> Source)
> 	at org.yarl.om.BaseRuntypePeer.doSelect(Unknown Source)
> 	at org.yarl.swing.RunHistoryFrame.addButtons(Unknown Source)
> 	at org.yarl.swing.RunHistoryFrame.initializeMe(Unknown Source)
> 	at org.yarl.swing.RunHistoryFrame.<init>(Unknown Source)
> 	at org.yarl.swing.RunnerListFrame.addRunHistoryFrame(Unknown
> Source)
> 	at org.yarl.swing.RunnerListFrame.access$300(Unknown Source)
> 	at org.yarl.swing.RunnerListFrame$4.actionPerformed(Unknown
> Source)
> 	at
> javax.swing.AbstractButton.fireActionPerformed(AbstractButton.
> java:1767)
> 	at
> javax.swing.AbstractButton$ForwardActionEvents.actionPerformed
> (AbstractButton.java:1820)
> 	at
> javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButt
> onModel.java:419)
> 	at
> javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
> 	at
> javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Basic
> ButtonListener.java:258)
> 	at java.awt.Component.processMouseEvent(Component.java:5021)
> 	at java.awt.Component.processEvent(Component.java:4818)
> 	at java.awt.Container.processEvent(Container.java:1380)
> 	at java.awt.Component.dispatchEventImpl(Component.java:3526)
> 	at java.awt.Container.dispatchEventImpl(Container.java:1437)
> 	at java.awt.Component.dispatchEvent(Component.java:3367)
> 	at
> java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3214)
> 	at
> java.awt.LightweightDispatcher.processMouseEvent(Container.java:2929)
> 	at
> java.awt.LightweightDispatcher.dispatchEvent(Container.java:2859)
> 	at java.awt.Container.dispatchEventImpl(Container.java:1423)
> 	at java.awt.Window.dispatchEventImpl(Window.java:1566)
> 	at java.awt.Component.dispatchEvent(Component.java:3367)
> 	at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
> 	at
> java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDis
> patchThread.java:190)
> 	at
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispa
> tchThread.java:144)
> 	at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
> 	at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
> 	at
> java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
> rethrown as org.apache.torque.TorqueException
> 	 at
> org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1273)
> 	at org.yarl.om.BaseRuntypePeer.doSelectVillageRecords(Unknown
> Source)
> 	at org.yarl.om.BaseRuntypePeer.doSelectVillageRecords(Unknown
> Source)
> 	at org.yarl.om.BaseRuntypePeer.doSelect(Unknown Source)
> 	at org.yarl.swing.RunHistoryFrame.addButtons(Unknown Source)
> 	at org.yarl.swing.RunHistoryFrame.initializeMe(Unknown Source)
> 	at org.yarl.swing.RunHistoryFrame.<init>(Unknown Source)
> 	at org.yarl.swing.RunnerListFrame.addRunHistoryFrame(Unknown
> Source)
> 	at org.yarl.swing.RunnerListFrame.access$300(Unknown Source)
> 	at org.yarl.swing.RunnerListFrame$4.actionPerformed(Unknown
> Source)
> 	at
> javax.swing.AbstractButton.fireActionPerformed(AbstractButton.
> java:1767)
> 	at
> javax.swing.AbstractButton$ForwardActionEvents.actionPerformed
> (AbstractButton.java:1820)
> 	at
> javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButt
> onModel.java:419)
> 	at
> javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
> 	at
> javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Basic
> ButtonListener.java:258)
> 	at java.awt.Component.processMouseEvent(Component.java:5021)
> 	at java.awt.Component.processEvent(Component.java:4818)
> 	at java.awt.Container.processEvent(Container.java:1380)
> 	at java.awt.Component.dispatchEventImpl(Component.java:3526)
> 	at java.awt.Container.dispatchEventImpl(Container.java:1437)
> 	at java.awt.Component.dispatchEvent(Component.java:3367)
> 	at
> java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3214)
> 	at
> java.awt.LightweightDispatcher.processMouseEvent(Container.java:2929)
> 	at
> java.awt.LightweightDispatcher.dispatchEvent(Container.java:2859)
> 	at java.awt.Container.dispatchEventImpl(Container.java:1423)
> 	at java.awt.Window.dispatchEventImpl(Window.java:1566)
> 	at java.awt.Component.dispatchEvent(Component.java:3367)
> 	at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
> 	at
> java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDis
> patchThread.java:190)
> 	at
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispa
> tchThread.java:144)
> 	at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
> 	at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
> 	at
> java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
> Caused by: java.lang.NullPointerException
>        at
> org.apache.torque.util.BasePeer.createQueryString(BasePeer.java:1168)
> 	at
> org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1260)
> 	... 32 more
> java.lang.NullPointerException
> 	at org.yarl.swing.RunHistoryFrame.addButtons(Unknown Source)
> 	at org.yarl.swing.RunHistoryFrame.initializeMe(Unknown Source)
> 	at org.yarl.swing.RunHistoryFrame.<init>(Unknown Source)
> 	at org.yarl.swing.RunnerListFrame.addRunHistoryFrame(Unknown
> Source)
> 	at org.yarl.swing.RunnerListFrame.access$300(Unknown Source)
> 	at org.yarl.swing.RunnerListFrame$4.actionPerformed(Unknown
> Source)
> 	at
> javax.swing.AbstractButton.fireActionPerformed(AbstractButton.
> java:1767)
> 	at
> javax.swing.AbstractButton$ForwardActionEvents.actionPerformed
> (AbstractButton.java:1820)
> 	at
> javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButt
> onModel.java:419)
> 	at
> javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
> 	at
> javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Basic
> ButtonListener.java:258)
> 	at java.awt.Component.processMouseEvent(Component.java:5021)
> 	at java.awt.Component.processEvent(Component.java:4818)
> 	at java.awt.Container.processEvent(Container.java:1380)
> 	at java.awt.Component.dispatchEventImpl(Component.java:3526)
> 	at java.awt.Container.dispatchEventImpl(Container.java:1437)
> 	at java.awt.Component.dispatchEvent(Component.java:3367)
> 	at
> java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3214)
> 	at
> java.awt.LightweightDispatcher.processMouseEvent(Container.java:2929)
> 	at
> java.awt.LightweightDispatcher.dispatchEvent(Container.java:2859)
> 	at java.awt.Container.dispatchEventImpl(Container.java:1423)
> 	at java.awt.Window.dispatchEventImpl(Window.java:1566)
> 	at java.awt.Component.dispatchEvent(Component.java:3367)
> 	at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
> 	at
> java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDis
> patchThread.java:190)
> 	at
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispa
> tchThread.java:144)
> 	at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
> 	at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
> 	at
> java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
> 
> schema:
> 
> <?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?> 
> <!DOCTYPE database SYSTEM 
> "http://jakarta.apache.org/turbine/dtd/database.dtd">
> 
> <database>
> 
>   <table name="Constant">
>     <column name="ConstantKey" required="true" 
>             primaryKey="true" type="INTEGER"/>
>     <column name="ConstantValue" required="true" size="255"
>             type="VARCHAR"/>
>   </table>
> 	    
>   <table name="Course">
>     <column name="CourseId" required="true" autoIncrement="true"
>             primaryKey="true" type="INTEGER"/>
>     <column name="RunnerId" required="true" type="INTEGER"/>
>     <column name="CourseName" required="true" size="64" 
> type="VARCHAR"/>
>     <column name="CourseNotes" required="false" size="1024" 
> type="VARCHAR"/>
>     <column name="CourseCity" required="false" size="64" 
> type="VARCHAR"/>
>     <column name="CourseState" required="false" size="2" type="CHAR"/>
>     <column name="CourseAccuracy" required="false" size="1" 
> type="CHAR"/>
>     <column name="CourseDefault" required="false" size="1" 
> type="CHAR"/>
> 
>     <foreign-key foreignTable="Runner">
>         <reference local="RunnerId" foreign="RunnerId"/>
>     </foreign-key>
>   </table>
> 
>   <table name="Runner">
>     <column name="RunnerId" required="true" autoIncrement="true"
>             primaryKey="true" type="INTEGER"/>
>     <column name="RunnerName" required="true" size="64" 
> type="VARCHAR"/>
>     <column name="RunnerBirthday" required="false" type="DATE"/>
>     <column name="RunnerGender" required="false" size="1" 
> type="CHAR"/>
>     <column name="RunnerHeight" required="false" type="FLOAT"/>
>     <column name="RunnerSpecies" required="false" size="32" 
> type="VARCHAR"/>
>     <column name="RunnerDefault" required="false" size="1" 
> type="CHAR"/>
>     <column name="RunnerMetric" required="false" size="1" 
> type="CHAR"/>
>     <column name="RunnerEmailAddress" required="false" size="128"
>                   type="VARCHAR"/>
>     <column name="RunnerAutoEmail" required="false" size="1" 
> type="CHAR"/>
>     <column name="RunnerSmtpServer" required="false" size="128"
>                   type="VARCHAR"/>
>     <column name="RunnerSmtpUserid" required="false" size="128"
>                   type="VARCHAR"/>
>     <column name="RunnerSmtpPswd" required="false" size="128" 
> type="VARCHAR"/>
>     <column name="RunnerWeekStartDay" required="true" size="3"
>                   type="CHAR"/>
>     <column name="RunnerPassword" required="false" size="64" 
> type="VARCHAR"/>
>   </table>
> 
>   <table name="Run">
>     <column name="RunId" required="true" autoIncrement="true"
>             primaryKey="true" type="INTEGER"/>
>     <column name="RunnerId" required="true" type="INTEGER"/>
>     <column name="RunDate" required="true" type="DATE"/>
>     <column name="RunTime" required="false" type="INTEGER"/>
>     <column name="RunTemp" required="false" type="INTEGER"/>
>     <column name="RunHumidity" required="false" type="INTEGER"/>
>     <column name="CourseId" required="true" type="INTEGER"/>
>     <column name="RunWindSpeed" required="false" type="INTEGER"/>
>     <column name="RunWindDirection" required="false" size="4"
>                   type="CHAR"/>
>     <column name="ShoeId" required="true" type="INTEGER"/>
>     <column name="RunTypeId" required="true" type="INTEGER"/>
>     <column name="RunWeight" required="false" type="FLOAT"/>
>     <column name="RunNotes" required="false" size="1024" 
> type="VARCHAR"/>
>     <column name="RunHR" required="false" type="FLOAT"/>
>     <column name="RunMorningHR" required="false" type="FLOAT"/>
>     <column name="RunSleepTime" required="false" type="FLOAT"/>
>     <column name="RunSleepQuality" required="false" size="4"
>             type="CHAR"/>
>     <column name="RunInjuryNotes" required="false" 
> size="1024" type="VARCHAR"/>
>     <column name="RunWithWhom" required="false" size="32"
>             type="VARCHAR"/>
>     <column name="RunPerceivedExertion" required="false"
>             type="INTEGER"/>
> 	
>     <foreign-key foreignTable="Runner">
>         <reference local="RunnerId" foreign="RunnerId"/>
>     </foreign-key>
> 
>     <foreign-key foreignTable="RunType">
>         <reference local="RunTypeId" foreign="RunTypeId"/>
>     </foreign-key>
> 
>     <foreign-key foreignTable="Course">
>         <reference local="CourseId" foreign="CourseId"/>
>     </foreign-key>
> 
>     <foreign-key foreignTable="Shoe">
>         <reference local="ShoeId" foreign="ShoeId"/>
>     </foreign-key>
>   </table>
> 
>   <table name="Lap">
>     <column name="LapId" required="true" autoIncrement="true"
>             primaryKey="true" type="INTEGER"/>
>     <column name="RunId" required="true" type="INTEGER"/>
>     <column name="LapNumber" required="true" type="INTEGER"/>
>     <column name="RunnerId" required="true" type="INTEGER"/>
>     <column name="LapDistance" required="true" type="FLOAT"/>
>     <column name="LapTime" required="true" type="FLOAT"/>
>     <column name="RunTypeId" required="true" type="INTEGER"/>
>     <column name="LapHR" required="false" type="FLOAT"/>
>     <column name="LapRecoveryTime" required="false" type="FLOAT"/>
>     <column name="LapRecoveryDistance" required="false" type="FLOAT"/>
>     <column name="LapRecoveryHR" required="false" type="FLOAT"/>
>     <column name="LapNotes" required="false" size="1024" 
> type="VARCHAR"/>
> 
>     <index name="idxLap0">
>         <index-column name="RunId"/>
>     </index>
> 
>     <foreign-key foreignTable="Run">
>         <reference local="RunId" foreign="RunId"/>
>     </foreign-key>
> 	
>     <foreign-key foreignTable="Runner">
>         <reference local="RunnerId" foreign="RunnerId"/>
>     </foreign-key>
> 
>     <foreign-key foreignTable="RunType">
>         <reference local="RunTypeId" foreign="RunTypeId"/>
>     </foreign-key>
>   </table>  
> 
>   <table name="Pr">
>     <column name="PrId" required="true" autoIncrement="true"
>             primaryKey="true" type="INTEGER"/>
>     <column name="RunnerId" required="true" type="INTEGER"/>
>     <column name="RunTypeId" required="true" type="INTEGER"/>
>     <column name="RunId" required="false" type="INTEGER"/>
>     <column name="PrDate" required="false" type="DATE"/>
>     <column name="PrDistance" required="false" type="FLOAT"/>
>     <column name="PrTime" required="false" type="FLOAT"/>
>     <column name="PrNotes" required="false" size="1024" 
> type="VARCHAR"/>
>     <column name="CourseId" required="false" type="INTEGER"/>
> 		
>     <index name="idxPr0">
>         <index-column name="RunnerId"/>
>     </index>
> 
>     <foreign-key foreignTable="Run">
>         <reference local="RunId" foreign="RunId"/>
>     </foreign-key>
> 	
>     <foreign-key foreignTable="Runner">
>         <reference local="RunnerId" foreign="RunnerId"/>
>     </foreign-key>
> 
>     <foreign-key foreignTable="RunType">
>         <reference local="RunTypeId" foreign="RunTypeId"/>
>     </foreign-key>
> 
>     <foreign-key foreignTable="Course">
>         <reference local="CourseId" foreign="CourseId"/>
>     </foreign-key>
>   </table>
> 
>   <table name="Rp">
>     <column name="RpId" required="true" autoIncrement="true"
>             primaryKey="true" type="INTEGER"/>
>     <column name="RunnerId" required="true" type="INTEGER"/>
>     <column name="RpEmailAddress" required="true" size="128"
>                 type="VARCHAR"/> 
>     <column name="RpAutoEmail" required="false" size="1" type="CHAR"/>
> 		
>     <foreign-key foreignTable="Runner">
>         <reference local="RunnerId" foreign="RunnerId"/>
>     </foreign-key>
> 
>   </table>
> 
>   <table name="RunType">
>     <column name="RunTypeId" required="true" autoIncrement="true"
>             primaryKey="true" type="INTEGER"/>
>     <column name="RunnerId" required="true" type="INTEGER"/>
>     <column name="RunType" required="true" size="16" type="VARCHAR"/>
>     <column name="RunTypeDescription" required="false" 
> size="1024" type="VARCHAR"/>
>     <column name="RunTypeIsQuality" required="false" size="1"
>             type="CHAR"/>
>     <column name="RunTypeTrackPr" required="false" size="1"
>             type="CHAR"/>
>     <column name="RunDefault" required="false" size="1"
>             type="CHAR"/>
>     <column name="WorkoutTypeName" required="false" size="16" 
> type="VARCHAR"/>
> 	
>     <foreign-key foreignTable="Runner">
>         <reference local="RunnerId" foreign="RunnerId"/>
>     </foreign-key>
>     <foreign-key foreignTable="WorkoutType">
>         <reference local="WorkoutTypeName" foreign="WorkoutTypeName"/>
>     </foreign-key>
> 
>   </table>
> 
>   <table name="Shoe">
>     <column name="ShoeId" required="true" autoIncrement="true"
>             primaryKey="true" type="INTEGER"/>
>     <column name="RunnerId" required="true" type="INTEGER"/>
>     <column name="ShoeNickname" required="true" size="32" 
> type="VARCHAR"/>
>     <column name="ShoeDatePurchased" required="false" type="DATE"/>
>     <column name="ShoeManufacturer" required="false" size="32"
>             type="VARCHAR"/>
>     <column name="ShoeModel" required="false" size="64"
>             type="VARCHAR"/>
>     <column name="ShoeModelYear" required="false" type="FLOAT"/>
>     <column name="ShoeNotes" required="false" size="1024" 
> type="VARCHAR"/>
>     <column name="ShoeRetired" required="false" size="1"
>             type="CHAR"/>
>     <column name="ShoeDefault" required="false" size="1" type="CHAR"/>
> 	
>     <foreign-key foreignTable="Runner">
>         <reference local="RunnerId" foreign="RunnerId"/>
>     </foreign-key>
> 
>   </table>
> 
>   <table name="WorkoutType">
>     <column name="WorkoutTypeName" required="true" size="16" 
> type="VARCHAR"
>             primaryKey="true"/>
>     <column name="WorkoutTypeDesc" required="false" 
> size="512" type="VARCHAR"/>
> 
>   </table>
> 
> </database>  
> 
> 
> environment info:
> 
> torque 3.0
> ant 1.5.1
> jdk 1.3.0_02
> mysql 3.23
> win2k (tried it on Linux with same results)
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:turbine-torque-dev-> unsubscribe@jakarta.apache.org>
> 
> For additional commands, 
> e-mail: <mailto:turbine-torque-dev-help@jakarta.apache.org>
> 
> 

Mime
View raw message