You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Fredrik Liden <fl...@translate.com> on 2007/06/06 22:53:36 UTC

Remove Foreign Keys Mapped as Object Attributes

When I synch the dbentity with the object I get the following prompt:

"Remove foreign keys mapped as Object Attributes."

Could someone explain what this one does? What are the pros and cons of
removing the foreign keys?

This is a 1-many relationship.

Table 1
Pk1
Field1

Table 2
Pk2
Field2
Fk2_pk1

Thanks,

Fredrik


Re: Remove Foreign Keys Mapped as Object Attributes

Posted by Mike Kienenberger <mk...@gmail.com>.
Yes, you generally want to do this.

It means that you are going to let Cayenne manage the foreign and
primary keys for the entities involved.     Then, instead of having to
deal with

table2.setFk2pk1Field(Table1.somehowGetPrimaryKeyWhichMightNotBeComputedYet())

all you need to do is

table2.setFk2pk1Relationship(table1);


On 6/6/07, Fredrik Liden <fl...@translate.com> wrote:
> When I synch the dbentity with the object I get the following prompt:
>
> "Remove foreign keys mapped as Object Attributes."
>
> Could someone explain what this one does? What are the pros and cons of
> removing the foreign keys?
>
> This is a 1-many relationship.
>
> Table 1
> Pk1
> Field1
>
> Table 2
> Pk2
> Field2
> Fk2_pk1
>
> Thanks,
>
> Fredrik
>
>