You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Tr...@novainfo.com on 2004/03/02 14:10:40 UTC

simple join problem

I am trying to make a simple join.  Below is the Criteria I am using:

  Criteria crit = new Criteria();
  crit.add(ViRejPeer.ASSN_REJ_ID, AssnRejPeer.ASSN_REJ_ID);
  crit.add(AssnRejPeer.REJ_STATUS_ID, 1000);

The query does not work because of an "invalid number".  I know what is
causing the Oracle error.  The Criteria produces the following query:

  SELECT * 
  FROM assn_rej, vi_rej 
  WHERE assn_rej.REJ_STATUS_ID=1000 
  AND vi_rej.ASSN_REJ_ID='assn_rej.ASSN_REJ_ID'

The cause of the problem is the assn_rej.ASSN_REJ_ID value surrounded by
quotes.  If the query is run on it's own without the quotes it runs fine.
So, I started looking into the join provided by the Peer base class.  The
problem with this is that we are managing our datasources with application
server so I would need to pass a connection into the join method.  This
option does not exist.  So my question, I suppose, is two-fold.  First, what
am I doing wrong with the above Criteria.  Second, is there a way to use the
join methods in the Peer classes and still pass in a Connection?

Travis

Note:  The information contained in this email and in any attachments is
intended only for the person or entity to which it is addressed and may
contain confidential and/or privileged material.  Any review,
retransmission, dissemination or other use of, or taking of any action in
reliance upon, this information by persons or entities other than the
intended recipient is prohibited.  The recipient should check this email and
any attachments for the presence of viruses.  Sender accepts no liability
for any damages caused by any virus transmitted by this email. If you have
received this email in error, please notify us immediately by replying to
the message and delete the email from your computer.  This e-mail is and any
response to it will be unencrypted and, therefore, potentially unsecure.
Thank you.  NOVA Information Systems, Inc.

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


Re: simple join problem

Posted by Andras Balogh <an...@reea.net>.
    Hello,

You should use
Crieteria.addJoin(ViRejPeer.ASSN_REJ_ID, AssnRejPeer.ASSN_REJ_ID);
ot better if the relationship is declared as foriegn key in your schema 
you should have
a protected method in you BaseViRejPeer:

ViRejPeer.doSelectJoinAssnRej(crit) (or somethig like that :))

Make this method public in 
ViRejPeer and use it .

Best wishes,
Andras.


Travis.Prescott@novainfo.com wrote:

>I am trying to make a simple join.  Below is the Criteria I am using:
>
>  Criteria crit = new Criteria();
>  crit.add(ViRejPeer.ASSN_REJ_ID, AssnRejPeer.ASSN_REJ_ID);
>  crit.add(AssnRejPeer.REJ_STATUS_ID, 1000);
>
>The query does not work because of an "invalid number".  I know what is
>causing the Oracle error.  The Criteria produces the following query:
>
>  SELECT * 
>  FROM assn_rej, vi_rej 
>  WHERE assn_rej.REJ_STATUS_ID=1000 
>  AND vi_rej.ASSN_REJ_ID='assn_rej.ASSN_REJ_ID'
>
>The cause of the problem is the assn_rej.ASSN_REJ_ID value surrounded by
>quotes.  If the query is run on it's own without the quotes it runs fine.
>So, I started looking into the join provided by the Peer base class.  The
>problem with this is that we are managing our datasources with application
>server so I would need to pass a connection into the join method.  This
>option does not exist.  So my question, I suppose, is two-fold.  First, what
>am I doing wrong with the above Criteria.  Second, is there a way to use the
>join methods in the Peer classes and still pass in a Connection?
>
>Travis
>  
>



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