cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Markus Reich <markus.re...@markusreich.at>
Subject Re: Relationship
Date Tue, 23 Apr 2013 13:21:30 GMT
ok, e.g. I have a table comments with following columns
ID               => Unique key of table comments
OBJECT      => Not null, identifies the entity the comment is for
OBJECTID   => Not null, key of the entity
COMMENT  => Comments as VARCHAR

example data
1  ORDER  12345  This is a comment for order 12345
2  ORDER  56789  This is a comment for order 56789
3  BILLING 11111  This is a comment for the billing 11111

Now there's a table orders and a table billings (both have a unique ID
column), so I want relationships like
SELECT * FROM order JOIN comments ON comments.OBJECT = 'ORDER' AND
comments.ID = order.ID
and
SELECT * FROM billings JOIN comments ON comments.OBJECT = 'BILLING' AND
comments.ID = billing.ID

Meex









2013/4/23 Mike Kienenberger <mkienenb@gmail.com>

> I don't quite understand the question you are asking.
>
> Can you give us an example of what you are trying to do with your
> comment table?   Some code using your desired mapping would be best.
>
>
> On Tue, Apr 23, 2013 at 12:49 AM, Markus Reich
> <markus.reich@markusreich.at> wrote:
> > Hi,
> >
> > with the wonderful Cayenne Modeler it's possible to easily create
> relations
> > between DB entities.
> > In my case I have a central table for comments, with a key specifying the
> > content.
> > No I need to map this key field to a constant literal, as I know it is
> just
> > possible to join fields with fields of the target entity :-(
> > Is there a workaround (I don't like to make a lot of views an join them
> ;-))
> >
> > regards
> > Meex
>



-- 
*Markus Reich*
Moosbach 28/2
6392 St. Jakob i.H.
www.markusreich.at / www.meeximum.at
markus.reich@markusreich.at

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message