cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aristedes Maniatis <...@maniatis.org>
Subject Re: Relationship
Date Wed, 24 Apr 2013 02:12:06 GMT
So what you are doing is creating a polymorphic join. One Cayenne way to model this is with
inheritance and I've discussed this approach before:

http://markmail.org/message/6xdboo2ygrcmp6p3

Ari

On 23/04/13 11:21pm, Markus Reich wrote:
> 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
>>
>
>
>

-- 
-------------------------->
Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

Mime
View raw message