I appreciate your design advice, but it doesn't have anything to do with
Torque, which is what my original question was about. Allow me to submit
several related questions which are more precise and should be easier to
answer:
1. When using Torque, if you have established a composite key for a table by
setting the 'primaryKey' attribute to 'true' for more than one column, and
both columns have integer types, will Torque automatically populate these
columns with values from the IDBroker, like it will for a simple primary
key?
2. If the answer to 1. is 'no', which I suspect it is, then is this how you
set the value of the primary key?
Transaction transaction = new Transaction();
NumberKey pk0 = new NumberKey(0);
NumberKey pk1 = new NumberKey(1);
NumberKey[] keys = {pk0, pk1};
transaction.setPrimaryKey(new ComboKey(keys));
transaction.save();
Thank you,
David
-----Original Message-----
From: Kurt Schrader [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 19, 2002 8:02 AM
To: Turbine Torque Users List
Subject: RE: How to use ComboKey?
On Thu, 18 Apr 2002 [EMAIL PROTECTED] wrote:
> I understand your warnings against a primary key having any informational
> content, though this admonition has always made me wonder why we still
have
> composite keys around. In the context of Torque, it again makes me
wonder,
> why do we have ComboKey around?
Backwards compatability.
<cut>
> I may, as you suggest, add a new column--say RECORD_ID--and make it the
> simple primary key, thus stripping all information from the primary key as
> you suggest. One consequence of this is that I will no longer be looking
> things up by their primary key, but instead by a combination of two
> attributes.
Yes, but that is what you will essentailly be doing anyway, it just
doesn't tie you to always looking things up in that manner. Your logic is
most likely going to look like :
transaction = getTransaction(x);
record = transaction.getGetRecordWithGreatestLogValue();
so I don't see what having a combo key gains you. All of my tables have a
UNIQID column that is the primary key. I've never come across a situation
where having a primary without meaning has hindered me.
-Kurt
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>