You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Ken Anderson <ke...@amphorainc.com> on 2017/04/17 16:11:38 UTC

Poorly modeled to-one relationship help

All,

We have a situation in our database that seems to require some special tricks in Cayenne to make work.  One of our developers is having issues with the following situation:

Table                      Primary Key

cost                        cost_num
cost_ext_info       cost_num

The cost_ext_info table just has the same primary key that the cost table has.  We use custom primary key generation for cost (grabs from another table), but how do we setup the relationship so the cost_num is propagated from the cost table when we insert both at the same time?

In WO, I would make the relationship to-many, and it would propagate the primary key down.  If we try that in Cayenne, it still tries to fill in the primary key of cost_ext_info before propagating apparently (since we’re getting an error that it can’t create a primary key for cost_ext_info).

Thoughts?  Many thanks in advance.

Ken

Ken Anderson
CTO Amphora, Inc.
Mobile:   +1 914 262 8540

[id:image001.png@01CE8142.D18AEB10]

www.amphorainc.com<http://www.amphorainc.com/>

Confidentiality Notice: This e-mail and accompanying documents contain confidential information intended for a specific individual and purpose. This e-mailed information is private and protected by law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, or distribution, or the taking of any action based on the contents of this information, is strictly prohibited.

Re: Poorly modeled to-one relationship help

Posted by Mike Kienenberger <mk...@gmail.com>.
Set the as "toDep PK" property as true for the db relationship from cost to
cost_ext_info for the COST DbEntity.

https://www.google.com/search?q=cayenne+dependent+primary+key

On Mon, Apr 17, 2017 at 12:11 PM, Ken Anderson <ke...@amphorainc.com>
wrote:

> All,
>
>
>
> We have a situation in our database that seems to require some special
> tricks in Cayenne to make work.  One of our developers is having issues
> with the following situation:
>
>
>
> Table                      Primary Key
>
>
>
> cost                        cost_num
>
> cost_ext_info       cost_num
>
>
>
> The cost_ext_info table just has the same primary key that the cost table
> has.  We use custom primary key generation for cost (grabs from another
> table), but how do we setup the relationship so the cost_num is propagated
> from the cost table when we insert both at the same time?
>
>
>
> In WO, I would make the relationship to-many, and it would propagate the
> primary key down.  If we try that in Cayenne, it still tries to fill in the
> primary key of cost_ext_info before propagating apparently (since we’re
> getting an error that it can’t create a primary key for cost_ext_info).
>
>
>
> Thoughts?  Many thanks in advance.
>
>
>
> Ken
>
>
>
> *Ken Anderson*
>
> CTO Amphora, Inc.
>
> Mobile:   +1 914 262 8540 <(914)%20262-8540>
>
>
>
> [image: id:image001.png@01CE8142.D18AEB10]
>
>
> www.amphorainc.com
>
>
> Confidentiality Notice: This e-mail and accompanying documents contain
> confidential information intended for a specific individual and purpose.
> This e-mailed information is private and protected by law. If you are not
> the intended recipient, you are hereby notified that any disclosure,
> copying, or distribution, or the taking of any action based on the contents
> of this information, is strictly prohibited.
>