You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Schönfisch, Jörg <jo...@softplant.de> on 2012/03/22 16:40:08 UTC

Why are most flattened relationships read-only?

Hi everybody,

I'm trying to create a model which uses multiple levels of inheritance. Because of this, I use many (flattened) 1:n-relationships between tables and subtables. Unfortunately, this results in read-only relationships on deeper levels of the hierarchy.
Is there any possibility to establish such a read-only relationship with Cayenne? Otherwise the model is practically unusable as I have no existing data and solely want to create it through the ORM.
I wonder if there is any practical reason why flattened relationships are read-only? Or is only the implementation to handle these lacking? Technically it should be possible to make them writable, at least if the flattened relationship spans only foreign key constraints.


Regards,

Joerg

AW: Why are most flattened relationships read-only?

Posted by Schönfisch, Jörg <jo...@softplant.de>.
I only need a writable flattened 1:n-ObjRelationship along a foreign key. Technically this should even be easier than a n:m-relationship.
Can you provide me a hint on where to look if I want to implement this?


-----Ursprüngliche Nachricht-----
Von: Aristedes Maniatis [mailto:ari@maniatis.org] 
Gesendet: Donnerstag, 22. März 2012 22:37
An: user@cayenne.apache.org
Betreff: Re: Why are most flattened relationships read-only?

On 23/03/12 2:40 AM, Schönfisch, Jörg wrote:
> Hi everybody,
>
> I'm trying to create a model which uses multiple levels of inheritance. Because of this, I use many (flattened) 1:n-relationships between tables and subtables. Unfortunately, this results in read-only relationships on deeper levels of the hierarchy.
> Is there any possibility to establish such a read-only relationship with Cayenne? Otherwise the model is practically unusable as I have no existing data and solely want to create it through the ORM.
> I wonder if there is any practical reason why flattened relationships are read-only? Or is only the implementation to handle these lacking? Technically it should be possible to make them writable, at least if the flattened relationship spans only foreign key constraints.


Since you have a special knowledge of your schema that Cayenne doesn't, perhaps you can write your own helper methods which know how to create the intermediate tables and all their required attributes. If the intermediate tables contain only foreign keys and nothing else, then Cayenne could potentially do what you want. But that often isn't the case.


Ari



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

Re: Why are most flattened relationships read-only?

Posted by Aristedes Maniatis <ar...@maniatis.org>.
On 23/03/12 2:40 AM, Schönfisch, Jörg wrote:
> Hi everybody,
>
> I'm trying to create a model which uses multiple levels of inheritance. Because of this, I use many (flattened) 1:n-relationships between tables and subtables. Unfortunately, this results in read-only relationships on deeper levels of the hierarchy.
> Is there any possibility to establish such a read-only relationship with Cayenne? Otherwise the model is practically unusable as I have no existing data and solely want to create it through the ORM.
> I wonder if there is any practical reason why flattened relationships are read-only? Or is only the implementation to handle these lacking? Technically it should be possible to make them writable, at least if the flattened relationship spans only foreign key constraints.


Since you have a special knowledge of your schema that Cayenne doesn't, perhaps you can write your own helper methods which know how to create the intermediate tables and all their required attributes. If the intermediate tables contain only foreign keys and nothing else, then Cayenne could potentially do what you want. But that often isn't the case.


Ari



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