You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Tim Drury <td...@siliconmotorsports.com> on 2003/03/06 23:15:47 UTC

map one object to two separate tables?

I have a generic Note object which is a child to two entirely
different parent objects.  I would like two note tables to store
the Note objects - one table for (e.g.) Invoice notes and one
table for Shipment notes.  I think two tables is necessary because
Invoices and Shipments have separate PK sequences and, therefore,
can generate duplicate values which would cause problems in a
single Note table.

Can OJB do this?  I couldn't figure out how to tell Invoices to
use the InvoiceNote table and Shipments to use the ShipmentNote
table.

I suppose a work-around would be to have two exact same but 
differently named interfaces for the Note object, but that seems
kludgy.

Thanks,

-tim



Re: map one object to two separate tables?

Posted by cw...@insect.com.
Tim,

You will need this as a reference:
http://db.apache.org/ojb/tutorial3.html#mapping%20m:n%20associations

In this case i would set my tables up like this
Note (noteId, noteTypeId, message)
InvoiceNote(invoiceId, noteId)
ShipmentNote(shipmentId, noteId)

You may need the note type so you will know if it is a invoice note or
shipment note.

Use the example in the link and apply it to what you are doing.  Instead
of Project, PersonProject Person you will have Invoice, InvoiceNote,
Invoice.

Hope that helps.

-chris worley
>
> I have a generic Note object which is a child to two entirely
> different parent objects.  I would like two note tables to store
> the Note objects - one table for (e.g.) Invoice notes and one
> table for Shipment notes.  I think two tables is necessary because
> Invoices and Shipments have separate PK sequences and, therefore,
> can generate duplicate values which would cause problems in a
> single Note table.
>
> Can OJB do this?  I couldn't figure out how to tell Invoices to
> use the InvoiceNote table and Shipments to use the ShipmentNote
> table.
>
> I suppose a work-around would be to have two exact same but
> differently named interfaces for the Note object, but that seems
> kludgy.
>
> Thanks,
>
> -tim
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>