db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brandon" <eff4...@hotmail.com>
Subject Re: problems with ordering
Date Wed, 09 Mar 2005 13:23:50 GMT
Hey Thomas, thanks for the response.  I fixed my problem but I can tell 
everyone how just for future reference.  I am using Cloudscape 10.0 and 
Torque 3.1.1.  The problem was addressed in the wiki and here was the answer 
Jorge Ortega gave:  "Another error may be at the OM generation. The database 
name was not specifed in then XML schema file. <database 
defaultIdMethod="idbroker" name="databaseName">".  So it wasn't anything 
wrong with my Java syntax.

I checked my schema file and sure enough the name attribute was not 
specified.  The XML file was made from an Ant JDBC task though!  So I opened 
the Torque source, found the TorqueJDBCTransformTask.java file (it's in 
org.apache.torque.task), and found where it added the database element. 
Since there is no particular explicit variable defined in that Java file for 
the name of the database I parsed the dbUrl string and got the name of the 
database.  So here was the line in the Java file to begin with where it 
creates the database tag in the XML file:

databaseNode = doc.createElement("database");

I simply added this line immediately after it (using the syntax for setting 
the attributes of a table):

dbUrl.substring(dbUrl.lastIndexOf("/")+1) );

Of course then I had to recompile that file, then find the .class file it 
created, open the torque-gen-3.1.1.jar, replace the existing 
TorqueJDBCTransformTask.class with my new one, and then recreate the jar and 
copy it into my project directory.  But now everything works and my database 
tag shows up with something like <database name="blah"> now.  :)


----- Original Message ----- 
From: "Thomas Fischer" <tfischer@apache.org>
To: <torque-user@db.apache.org>
Sent: Wednesday, March 09, 2005 5:28 AM
Subject: RE: problems with ordering

> 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

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

View raw message