db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <tfisc...@apache.org>
Subject RE: problems with ordering
Date Wed, 09 Mar 2005 10:28:35 GMT
Hi,

your code looks ok. There is something similar in the Runtimetest,
     public void testCriteriaOrderBy()
     {
         List books = null;
         try
         {
             Criteria criteria = new Criteria();
             criteria.addAscendingOrderByColumn(BookPeer.TITLE);
             criteria.addAscendingOrderByColumn(BookPeer.ISBN);

             books = BookPeer.doSelect(criteria);
         }
         catch (Exception e)
         {
             e.printStackTrace();
             fail("Exception caught : "
                      + e.getClass().getName()
                      + " : " + e.getMessage());
         }

which runs without problems.
Can you please send in the stacktrace of the NullPointerException, and 
state which Torque version you are using ?

   Thomas

Original Message:
I'm having trouble with ordering columns.  I'm not sure why, I've tried
debugging, but I always seems to get a null pointer exception, yet I can't
figure out what's null...maybe it's because I don't have the Torque source
in the debugger, so I lose my abililty to step through and really see 
what's
happening once I leave my generated classes.  But normally I'm getting a
list back, it's just not sorted.  So I installed p6spy to check the SQL 
and
see what was really going on.  So I made this simple little tester class 
to
see what's up and I get an exception when I try to order.  I have a DB
that's a fake doctor's office say, and it holds records of patients.  Any
idea why the code below wouldn't work, and any suggestions on how to add
ordering?  According to the Criteria tutorial, my code should work
perfectly.  All they have is
"criteria.addAscendingOrderByColumn(RolePeer.NAME);" and I do something 
very
similar.  The problem is obviously with the ordering method call.  If I
comment out that line, the code works and my list prints out...it's just 
not
sorted which is what I want to do.  Thanks!  -Brandon



public class Tester
{
 		 public static void main(String[] args)
 		 {
 		 		 try
 		 		 {

Torque.init("torque.properties");

 		 		 		 Criteria c = new 
Criteria();

c.addAscendingOrderByColumn(PatientPeer.LAST_NAME);
 		 		 		 List li = 
PatientPeer.doSelect(c);
 		 		 		 Iterator i = 
(Iterator)li.iterator();

 		 		 		 System.out.println("list 
1");
 		 		 		 while (i.hasNext())
 		 		 		 {
 		 		 		 		 Patient p 
= (Patient)i.next();

System.out.println(p.toString());
 		 		 		 }
 		 		 }
 		 		 catch (Exception e)
 		 		 {e.printStackTrace();}
 		 }
}


---------------------------------------------------------------------
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