db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sheng Guo <sh...@in.tum.de>
Subject Re: sql translation
Date Thu, 18 Mar 2004 21:09:11 GMT
Hello,

I tried this :

      java.util.List list = new ArrayList();
      Criteria crit = new Criteria();
      crit.addJoin(SYSContactUserPeer.SYS_CONTACT_ID, SYSContactPeer.ID);

      crit.addAscendingOrderByColumn(SYSContactUserPeer.ID);

      try {
      
        list =* BasePeer*.doSelect(crit);
       
        return list;
      }
      catch (Exception exc) {
        String message = exc.toString();
        System.out.println(message);
        return null;

      }

After that I run it under the application, and the exception said: 
org.apache.torque.TorqueException: ERROR:  parser: parse error at or 
near "FROM"

I think there is something wrong with the BasePeer class, shall I use 
this class, if I want to select 3 columns from the 2 joined tables. The 
sql statement looks like this:

select c.name, u.firstname, u.lastname
from   sys_contact c,  sys_contact_user u
where  u.sys_contact_id =  c.id

Thanks for any advice!

yours sincerely

Guo




Luca Zappa wrote:

>Hi Guo,
>  can you send us the xml schema of your db?
>
>If you define correctly foreing keys, that query is just implemented.
>Otherwise you can use Critera:
>
>Criteria c = new Criteria();
>c.addJoin(Table1Peer.PUBLISHER_ID,Table2Peer.PUBLISHER_ID);
>List rows = BasePeer.doSelect(c);
>
>Regards,
>  Luca
>
>-----Original Message-----
>From: Sheng Guo [mailto:sheng@in.tum.de] 
>Sent: Wednesday, March 17, 2004 9:03 PM
>To: torque-user@db.apache.org
>Subject: sql translation
>
>Hello,
>
>I am a new user of torque, and I would like to translate the following sql
>statement into torque,
>
>select c.name, u.firstname, u.lastname
>from   sys_contact c,  sys_contact_user u
>where  u.sys_contact_id =  c.id
>
>Could you please help me?
>
>yours sincerely
>
>Guo
>
>
>---------------------------------------------------------------------
>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
>
>
>  
>



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