i propose you define a m:n mapping between Test and Test_Panel with Panel_Test_Table as intermediate table.
i'm not sure about the pk Panel_Test_Table. in our examples the pk is the combined pk of the linked tables. afaik it's not possible to define a special pk for the intermediate table, but you could probably use an autoincrement feature of your dbms.
the other point is that Test ans Test_Panel are mapped to the same table. ojb uses the column ojbConcreteClass to distiguish the class in the table. this column is automatically added in QueryFactory and it's also used by RowReaderDefaultImpl to get the class to be instantiated.
protected ClassDescriptor selectClassDescriptor(Map row) throws PersistenceBrokerException
{
// check if there is an attribute which tells us which concrete class is to be instantiated
FieldDescriptor concreteClassFD = m_cld.getOjbConcreteClassField();
if (concreteClassFD == null)
return m_cld;
else
{
....you'll have to implement your own row-reader using the column 'category' to decide which class to use.
hth
jakob
Gary wrote:
Jakob:
Thanks for your quick reply.
--- Jakob Braeuchi <[EMAIL PROTECTED]> wrote:
hi gary,
imo the table Panel_Test_Table is a link table to
connect rows in Test_table, is that correct ?
Yes
Test_table test_key / category
55 / PA 10 / TE 15 / TE 66 / PA
Panel_Test_Table panel_test_key / panel_key / test_key
1 / 55 / 10 2 / 55 / 15 3 / 66 / 10
a test can be connected to multiple panels ?
Yes
is it a m:n relationship between Test_table rows ?
Yes, if I understand the question, when the
category >> is "PA"
what's the meaning of the panel_test_key ?---------------------------------------------------------------------
No meaning, just a unique ID for the row.
jakob
Gary wrote:
I have a, for me, complex OJB problem, and am
looking
for pointers.
I have two classes: a Test, and a PanelOfTests. I have two tables: Tests_Table, and
Panel_Test_Table.
Here is the pseudocode:
public class Test { int testID; String category; // can be "TE" for test, "PA"
for
panel }
public class PanelOfTests extends Test { Collection tests; // a collection of Test objects }
table Tests_Table test_key, int category, varchar
table Panel_Test_Table panel_test_key, int panel_key, int test_key, int
A PanelOfTests then is in fact a Test, one that
has a
category of "PA," and which contains 1-n other
Tests.
To find the tests that a given panel (say, 55) contains I get all the rows in Panel_Test_Table
where
panel_key = 55 and instantiate a Test object for
each
of the test_keys.
Any good ideas on how to do this in OJB
metadata/row
readers/? I am unable to change the database
layout.
Thanks, Gary
__________________________________ Do you Yahoo!? Yahoo! Mail - More reliable, more storage, less
spam
http://mail.yahoo.com
---------------------------------------------------------------------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]
__________________________________ Do you Yahoo!? Yahoo! Mail - More reliable, more storage, less spam http://mail.yahoo.com
--------------------------------------------------------------------- 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]
