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 Rob Gordon <rg...@mwt.net> on 2004/04/19 15:55:59 UTC
one-many object mappings
Hi--
Anyone have any experience with one-many mappings in schema?
Is it possible? Basically, I want something like getBasedOnForeignKey
to return a List, not a single object.
Rob
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org
Re: one-many object mappings
Posted by sk...@engr.uky.edu.
Hi,
First I will explain what I understand of your question -
You have an entity X which has many Y refering to it
through a foreign key in Y. And you want to get all Y's
that refer to X as a List.
It THAT is what you wanted, there is already one such
function available in Torque. You can do X.getYs() and
it will return a List of all Ys that refer to X. This IS a "s" after the "Y" in
the function name. You can then do something like this-
List Ylist = X.getYs();
Iterator i = Ylist.iterator();
while (i.hasNext())
{
Y yobj = (Y) i.next();
/* Do something in yobj. */
}
Hope this helps.
~Sarav
Quoting Rob Gordon <rg...@mwt.net>:
> Hi--
>
> Anyone have any experience with one-many mappings in schema?
> Is it possible? Basically, I want something like getBasedOnForeignKey
> to return a List, not a single object.
>
> Rob
>
>
>
> ---------------------------------------------------------------------
> 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
RE: one-many object mappings
Posted by Daniel Huang <da...@cisco.com>.
If your table OBJ has a foreign key into table A, torgue will generate
A.getObjs() that returns a list of OBJs whose foreign key equals the primary
key of the A being called from.
Regards,
Daniel
-----Original Message-----
From: Rob Gordon [mailto:rgordon@mwt.net]
Sent: Monday, April 19, 2004 6:56 AM
To: Apache Torque Users List
Subject: one-many object mappings
Hi--
Anyone have any experience with one-many mappings in schema?
Is it possible? Basically, I want something like getBasedOnForeignKey
to return a List, not a single object.
Rob
---------------------------------------------------------------------
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