You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Marc O'Morain <ma...@swrve.com> on 2011/09/04 14:11:41 UTC

Re: How do I do a relationship on non-PKs in Modeler?

Hi Jo,

I was able to do this in the past by editing the .map.xml file by hand to
add the relationships. To do this I added a foreign key on the database for
one table temporarily, and let Cayenne infer this relationship. This
produced the relationship that I needed. I was then able to delete the
foreign key, and hand-write the other relationships to match the first.

It worked surprisingly well, but the real fix is to add foreign keys to your
database.

Marc

On Fri, Aug 26, 2011 at 10:53 AM, Durchholz, Joachim <
Joachim.Durchholz@hennig-fahrzeugteile.de> wrote:

> Just to keep people informed: I have found the right incantation.
>
> As Joel has noted, it's an awful lot of steps.
> Also, Modeler isn't really very intuitive. For example, I'm entirely
> confused about what you're supposed to do with classes and what should be
> done with tables. Too many irregularly-formed Lego blocks (possible
> configuration options), too little explanations how they're supposed to work
> together.
>
> Just as a feedback. I'm not working actively with Modeler right now (we had
> to postpone the Hibernate->Cayenne migration), I'm pretty sure I'll be able
> to figure it all out once I have more time for this.
>
> Regards,
> Jo
>

RE: How do I do a relationship on non-PKs in Modeler?

Posted by "Durchholz, Joachim" <Jo...@hennig-fahrzeugteile.de>.
> I was able to do this in the past by editing the .map.xml file by hand to add the relationships.

Ouch.

> To do this I added a foreign key on the database for one table temporarily, and let Cayenne infer this relationship. This produced the relationship that I needed. I was then able to delete the foreign key, and hand-write the other relationships to match the first.

Heh. We wouldn't need to do that, since we do have foreign keys, so we already have a model to work from.

> It worked surprisingly well,

Good to hear that.
Though I'd prefer to be able to do that in Modeler. But well, you can't have everything.

> but the real fix is to add foreign keys to your database.

Not on views.
I can't even define them at the view level. Not in Oracle anyway.
And while I'd like the database to automatically infer the constraints on views from those specified at the table level, I'm not visionary enough to actually expect that to be available in my lifetime.

Regards,
Jo