On Jun 4, 2007, at 9:52 AM, John Armstrong wrote:
I can enforce it unique in the database but I was thinking that
Cayenne may have a more elegant way of managing it without having to
manually apply the database changes after schema creation. To me that
screamed 'New compound PK'.
To me it doesn't :-)
Seriously, ORM tool (CayenneModeler) doesn't attempt to replace your
DB management tools 100%, although it overlaps a lot. You should
still use DB facilities as appropriate.
How do you create compound PK's in Cayenne? I'm still using the
Modeller so I may have to edit the XML natively?
Go to the attributes tab of the given DbEntity and check the PK
checkboxes of those two extra columns.
But note that you would need to delete the "id" column then,
otherwise the UNIQUE constraint would span all three columns, not
just the two you wanted.
Also you would need to mark a relationship from ImapServer to the
table in question as "To Dep Pk", so that the serverid could be
propagated whenever you do myObject.setServer(myServer).
Andrus