db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Boehm" <bo...@nortelnetworks.com>
Subject Problem with addAscendingOrderByColumn -- NullPointerException with VARCHAR col, PostgreSQL
Date Thu, 08 Apr 2004 19:28:14 GMT
I'm using

ant 1.6.1
torque 3.1
postgresql 7.3.4

I get NullPointerException when using addAscendingOrderByColumn with a
column of type VARCHAR. It works fine for a timezone column.

I found some old messages on the mailing list from Dec 2002 and added 

database name="<name>" to my schema.

I am a novice Java and torque user so I am stumped as to where to go
next.

The code is

  public static void main( String[] args) {

    try {
      /*
       * Initializing Torque
       */
      Torque.init("Torque.properties");

      SimpleDateFormat df = new SimpleDateFormat( "yyyy-MM-dd HH:mm" );
      Calendar today      = new GregorianCalendar();

      today.set( Calendar.HOUR_OF_DAY, 16 );
      today.set( Calendar.MINUTE, 0 );

      String start        =  df.format( today.getTime() );
      System.out.println( start );

      today.add( Calendar.DAY_OF_MONTH, -3 );

      start               =  df.format( today.getTime() );
      System.out.println( start );

      Criteria crit = new Criteria();
      crit.addAsColumn( "date", "to_char( date_trunc( 'day', stime - cast( '16 hours' as interval
) ),'MM/DD')" );
      crit.addAsColumn( "elapsed", "(etime - stime)" );
      crit.add( BackmonPeer.STIME, (Object) start, Criteria.GREATER_EQUAL );
      crit.addAscendingOrderByColumn( BackmonPeer.STIME );
      crit.addAscendingOrderByColumn( BackmonPeer.HOST );
      System.out.println( crit );
      List backmonlist = BackmonPeer.doSelect( crit );
  
Stack trace is

225 [main] DEBUG dsfactory.TorqueDataSourceFactory  - Setting datasource property: url
230 [main] DEBUG dsfactory.TorqueDataSourceFactory  - Setting datasource property: user
231 [main] DEBUG dsfactory.TorqueDataSourceFactory  - Starting initTorqueClassic
252 [main] DEBUG dsfactory.TorqueDataSourceFactory  - Setting datasource property: defaultMaxConnections
259 [main] DEBUG dsfactory.TorqueDataSourceFactory  - Setting datasource property: maxExpiryTime
261 [main] DEBUG dsfactory.TorqueDataSourceFactory  - Setting datasource property: connectionWaitTimeout
262 [main] DEBUG torque.Torque  - Adding a dummy entry for default, mapped onto metrics
2004-04-08 16:00
2004-04-05 16:00
476 [Thread-1] DEBUG oid.IDBroker  - IDBroker thread was started.
Criteria:: backmon.STIME<=>backmon.STIME>='2004-04-05 16:00':  
Current Query SQL (may not be complete or applicable): 
java.lang.NullPointerException
        at org.apache.torque.util.BasePeer.createQuery(BasePeer.java:1219)
        at org.apache.torque.util.BasePeer.createQueryString(BasePeer.java:927)
        at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1321)
        at com.nortelnetworks.metrics.om.BaseBackmonPeer.doSelectVillageRecords(BaseBackmonPeer.java:409)
        at com.nortelnetworks.metrics.om.BaseBackmonPeer.doSelectVillageRecords(BaseBackmonPeer.java:376)
        at com.nortelnetworks.metrics.om.BaseBackmonPeer.doSelect(BaseBackmonPeer.java:345)
        at com.nortelnetworks.metrics.tool.BackmonTool.main(BackmonTool.java:53)
rethrown as org.apache.torque.TorqueException
        at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1334)
        at com.nortelnetworks.metrics.om.BaseBackmonPeer.doSelectVillageRecords(BaseBackmonPeer.java:409)
        at com.nortelnetworks.metrics.om.BaseBackmonPeer.doSelectVillageRecords(BaseBackmonPeer.java:376)
        at com.nortelnetworks.metrics.om.BaseBackmonPeer.doSelect(BaseBackmonPeer.java:345)
        at com.nortelnetworks.metrics.tool.BackmonTool.main(BackmonTool.java:53)
Caused by: java.lang.NullPointerException
        at org.apache.torque.util.BasePeer.createQuery(BasePeer.java:1219)
        at org.apache.torque.util.BasePeer.createQueryString(BasePeer.java:927)
        at org.apache.torque.util.BasePeer.doSelect(BasePeer.java:1321)
        ... 4 more
624 [Thread-3] DEBUG oid.IDBroker  - IDBroker thread was started.


The database schema is

<?xml version="1.0"?>
<!DOCTYPE database SYSTEM "http://jakarta.apache.org/turbine/dtd/database.dtd">
<!-- Autogenerated by JDBCToXMLSchema! -->
<database name="metrics">
    <table name="backmon">
        <column name="backid" required="true" type="VARCHAR"/>
        <column name="host" required="true" type="VARCHAR"/>
        <column name="bclass" required="true" type="VARCHAR"/>
        <column name="status" required="true" type="VARCHAR"/>
        <column name="stime" type="TIMESTAMP"/>
        <column name="etime" type="TIMESTAMP"/>
        <column name="phaseinfo" type="VARCHAR"/>
        <column name="schedule" type="VARCHAR"/>
        <column name="btype" type="VARCHAR"/>
        <column name="modtime" type="TIMESTAMP"/>
        <column name="exitcode" type="INTEGER"/>
    </table>
    <table name="backmon_archive">
        <column name="backid" type="VARCHAR"/>
        <column name="host" type="VARCHAR"/>
        <column name="bclass" type="VARCHAR"/>
        <column name="status" type="VARCHAR"/>
        <column name="stime" type="TIMESTAMP"/>
        <column name="etime" type="TIMESTAMP"/>
        <column name="phaseinfo" type="VARCHAR"/>
        <column name="schedule" type="VARCHAR"/>
        <column name="btype" type="VARCHAR"/>
        <column name="modtime" type="TIMESTAMP"/>
        <column name="exitcode" type="INTEGER"/>
    </table>
</database>

-- 
Eric M. Boehm                  /"\  ASCII Ribbon Campaign
boehm@nortelnetworks.com       \ /  No HTML or RTF in mail
                                X   No proprietary word-processing
Respect Open Standards         / \  files in mail

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message