Scott, problem is this works only for tables that are referenced by the foreign key. It should be possible to join two different tables and retrieve the respective columns of both tables as well (not only join them in the WHERE clause).
Marc > -----Ursprungliche Nachricht----- > Von: Scott Eade [mailto:[EMAIL PROTECTED]] > Gesendet: Samstag, 8. Februar 2003 13:44 > An: turbine-user > Betreff: Re: How addjoin of criteria works? > > > Marc is correct that this message would be better addressed to > [EMAIL PROTECTED] > > In answer to your question, if the foreign key is correctly > declared in your > schema, the torque generated classes will provide methods that do what you > are after. If you examine the generated classes you should find something > like: > > BaseForumnotesPeer.doSelectJoinForumtopic(criteria) > BaseForumnotes.getForumtopic() > BaseForumtopic.getForumnotes() > BaseForumtopic.getForumnotes(criteria) > BaseForumtopic.getForumnotesJoinForumtopic(criteria) > > I am pretty sure one of these will provide what you are after. You would > invoke these on Forumnotes or Forumtopic objects or the class > ForumnotesPeer > rather than the Base* subclasses. Some of the generated methods are > protected so as to require you to make a conscious decision to expose them > by overriding them in the extending class. > > HTH, > > Scott > -- > Scott Eade > Backstage Technologies Pty. Ltd. > http://www.backstagetech.com.au > .Mac Chat/AIM: seade at mac dot com > > On 8/02/2003 9:04 PM, "Zamek" <[EMAIL PROTECTED]> wrote: > > > Hi All, > > I read Criteria howto, but I don't understand working of criteria. > > Forexample: a forum apps has 2 table topic and notes. > Notes.fn_topic is a > > foreign key to topic.ft_id. > > > > If I would like to join its: > > > > Criteria criteria = new Criteria(); > > criteria.addJoin(ForumnotesPeer.FN_TOPIC, ForumtopicPeer.FT_ID); > > criteria.add (ForumnotesPeer.FN_ID, 1020); > > List res = ForumnotesPeer.doSelect(criteria); > > > > Yes it select all of forumnotes fields, but doesn't selects forumtopic's > > fields. > > Ok, when I add named columns to criteria with: > > criteria.addSelectColumn(ForumnotesPeer.FN_TEXT); > > criteria.addSelectColumn(ForumtopicPeer.FT_NAME); > > > > its sql is: > > select forumnotes.fn_text, forumtopic.ft_name from > > forumnotes, forumtopic > > where forumnotes.fn_id=1020 and > > forumnotes.fn_topic=forumtopic.ft_id; > > > > yes, it is very good. > > But res doesn't has forumtopic.ft_name value because > forumnotesPeer hasn't > > any field named ft_name; > > > > How can I get fields of joined tables in result list? > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
