Im having the same issue exactly, and was trying to figure out how to put
the question!
I have two tables, Product and Group. A product can only be in one group,
but a group has many products. Here are representative schemas:
table Product
ndx int primary key,
name varchar,
code varchar,
groupNdx int
table Group
ndx int primary key,
name varchar,
code varchar
So, im joining Product.groupNdx with Group.ndx. As I understand it, in the
schema definition for Product, you provide a reference descriptor for the
link to group, "groupNdx".
Im guessing, what happens is that groupNdx is matched with whatever the
primary key is on Group, since we've said it refers to the group class in
our reference descriptor.
But what if you're not joining on a primary key?
I see that in the torque schema, it very clearly indicates the local field
name and foreign field name in foreign key relationship definitions.
Similarly, in the OJB repository, for collections, there is a similar way
to provide that foreign field name. But not for reference descriptors..? Is
it just an oversight?
Finally, what if you're not joining on primary keys at all? What if I want
to say "give me all the names of pieces of art, that share an employee's
first name?"
In torque, it looks like they have addJoin() methods for criteria, so you
can link two arbirarily columns in two arbitary tables. How come this doesnt
exist for the OJB queries?
Oh, one last thing, one request is if the sql, jdbc, ojb-model, and
ojb-repository build targets and templates could be brought into the OJB
file structure and a "ready to customize for your app ant script" rather
than being hardcoded in the torque jarfile... This would allow us (as in the
OJB community, rather than the torque community) to take over maintenance of
the ojb-related templates if nothing else.
yours,
David Mitchell
-----Original Message-----
From: Robert S. Sfeir [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 13, 2003 10:34 AM
To: oJB List
Subject: foreign keys... again
Still a bit confused, If I have this:
<class-descriptor class="net.sfeir.business.RequestBO" table="REQUESTS">
<field-descriptor name="assignedToID" column="assignedTo"
jdbc-type="INTEGER"/>
...
and I want to setup a foreign key from assignedToID to another table
called Users and the column there is called userID
I added this as the foreign-key reference:
<reference-descriptor name="userBO"
class-ref="net.sfeir.security.business.UserBO">
<foreignkey field-ref="userID"/>
</reference-descriptor>
But it doesn't make any sense, if I put assignedToID in the field-ref,
how does it know the column I am mapping? If I put the userID like I
did in the field-ref how does it know that I am mapping assignedToID?
You can't always expect the table column names to match, most of the
time they won't.
I'm missing something here that would let me tell the descriptiptor.
The RequestBO object has a getter and setter which get back a UserBO as
suggested earlier, but even if it does a getUserBO() and it gets the
UserBO back, UserBO doesn't have a method called getAssignedTOID() nor
do I want to do that because that's breaking the OO rules of the
framework.
I'm totally confused right now and unfortunately, the docs are not very
clear.
R
--
Robert S. Sfeir
Senior Java Engineer
National Institutes of Health
Center for Information Technology
Department of Enterprise Custom Applications
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
+---------------------------------------------------------+
This message may contain confidential and/or privileged information. If you
are not the addressee or authorized to receive this for the addressee, you
must not use, copy, disclose or take any action based on this message or any
information herein. If you have received this message in error, please
advise the sender immediately by reply e-mail and delete this message.
Thank you for your cooperation.
+---------------------------------------------------------+
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]