To tell you the truth for all I care I can setup the join in the db or not at all. I just wanted to setup the fk syntax for development purposes only. Foreign keys always slow down insert, update and deletes and for performance reasons I don't put them in. So since this is just a development box, I can set things up manually to test things out. Once my code works it won't need the fk. Of course there is an advantage in OJB to having them because you can cascade deletes and auto populate a value, but I will be allowing neither of these in my case.




On Thursday, Feb 13, 2003, at 12:27 US/Eastern, Andrew Gilbert wrote:

I am new to OJB but have some input. I could be smoking something, so be warned...

If Product can only be associated with one Group, shouldn't one assume you would be referring to the Group using it's unique identity (primary key)? How else can you guarantee effeciency and uniqueness?

In the Collection case, it makes sense to support a field name, as now the assumption is there are N members in the set, not one.

As for more arbitrary join scenarios, you are getting at rub of the whole OO/Relational problem. There are generally a number of strategies, including explicit definition of N..M relationships, query by navigation or filtering (expensive!), explicit denormalization, or straight SQL/reporting.


-----Original Message-----
From: David Mitchell [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 13, 2003 11:57 AM
To: 'OJB Users List'
Subject: RE: foreign keys... again, joins, and OJB templates



 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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

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]

Reply via email to