You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Zamek <za...@vili.pmmf.hu> on 2003/02/08 11:04:26 UTC

How addjoin of criteria works?

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?

-- 
thx,
----------------------------------------------------
Zoltan Zidarics programmer
PTE University Pecs, Hungary
icq: 43288694

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


Updating groups, roles, etc.

Posted by Bruce Altner <ba...@hq.nasa.gov>.
Greetings:

It appears to be impossible to update a group name under Turbine 2.1. I 
found a couple of messages about this on the turbine-users list but no one 
ever responded with a solution. Flux gets the new name of the group and 
tries to save it. This fails with an UnknownEntityException because the old 
name was not provided. Putting the old name in a hidden input field and 
hacking FluxGroupAction only leads to further failures. I even tried 
messing with the GroupPeer classes directly, getting the GROUP_ID via 
doSelect(criteria) and then trying a doUpdate with the new name. This also 
generates an exception.

I understand the same problem occurs with roles and permissions.

Is there really no way to update the name of a group/role/permission in 
Turbine 2.1?

Thanks,
Bruce


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


Re: How addjoin of criteria works?

Posted by Scott Eade <se...@backstagetech.com.au>.
On 9/02/2003 2:18 AM, "Zamek" <za...@vili.pmmf.hu> wrote:

> thanks a lot, it works, but when I call doSelectJoinXXX, I cannot reference
> joined table fields.
> Forumtopic has a field named FT_NAME
> When I call BaseForumnotes.getForumtopic(), it has  getFtName() method.
> doSelectJoinXXX.getFtName() doesn't works.

doSelectJoinXXX() populates the fields for the current object and
per-populates the XXX list for the related object so that getXXX() (in your
case getForumtopics()) does not require further database access.

It is not a join as in an SQL join where all columns exist with repeated
data for the parent object, but rather an object equivalent whereby you have
the parent object that includes a List containing the child objects.

Does this make more sense?  This is far easier than having to deal with a
standard SQL join as you do not have to manually code for changes in parent
objects.

Scott
-- 
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
.Mac Chat/AIM: seade at mac dot com


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


Re: How addjoin of criteria works?

Posted by Zamek <za...@vili.pmmf.hu>.
Hi,

thanks a lot, it works, but when I call doSelectJoinXXX, I cannot reference 
joined table fields.
Forumtopic has a field named FT_NAME
When I call BaseForumnotes.getForumtopic(), it has  getFtName() method.
doSelectJoinXXX.getFtName() doesn't works.

at 2003. február 8. 13:43 wrote:
> Marc is correct that this message would be better addressed to
> torque-user@db.apache.org.
>
> 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

-- 
thx,
----------------------------------------------------
Zoltan Zidarics programmer
PTE University Pecs, Hungary
icq: 43288694

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


Re: AW: How addjoin of criteria works?

Posted by Scott Eade <se...@backstagetech.com.au>.
I think I am missing something.

You seem to be saying that you want to be able to do a join without
declaring the foreign key in the schema, is this correct?  Why not just
declare the relationship and go from there?  Or am I missing your point?

Scott
-- 
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
.Mac Chat/AIM: seade at mac dot com


On 9/02/2003 12:03 AM, "Marc Lustig" <ma...@marclustig.com> wrote:

> 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


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


AW: How addjoin of criteria works?

Posted by Marc Lustig <ma...@marclustig.com>.
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:seade@backstagetech.com.au]
> 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
> torque-user@db.apache.org.
>
> 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" <za...@vili.pmmf.hu> 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: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>


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


Re: How addjoin of criteria works?

Posted by Scott Eade <se...@backstagetech.com.au>.
Marc is correct that this message would be better addressed to
torque-user@db.apache.org.

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" <za...@vili.pmmf.hu> 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: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


AW: How addjoin of criteria works?

Posted by Marc Lustig <ma...@marclustig.com>.
Excellent question, I was also wondering about this...
But you should rather post it to the torque-list: torque-user@db.apache.org



> -----Ursprüngliche Nachricht-----
> Von: Zamek [mailto:zamek@vili.pmmf.hu]
> Gesendet: Samstag, 8. Februar 2003 11:04
> An: Turbine Users List
> Betreff: How addjoin of criteria works?
>
>
> 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?
>
> --
> thx,
> ----------------------------------------------------
> Zoltan Zidarics programmer
> PTE University Pecs, Hungary
> icq: 43288694
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>


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