You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Hugi Thordarson <hu...@karlmenn.is> on 2016/10/18 15:27:48 UTC

DB with totally manually managed primary keys

Hi all,
I’m currently working on a legacy DB where primary key values are both meaningful and completely manually managed in code (no automatic PK generation, sequences or anything, but have to be specified by the programmer).

How do I tell Cayenne to not attempt to create PKs?

Cheers,
- hugi

Re: DB with totally manually managed primary keys

Posted by Hugi Thordarson <hu...@karlmenn.is>.
Ah, of course everything works like a charm as soon as I’ve provided the value myself. Thanks Michael!

Cheers,
- hugi



> On 18. okt. 2016, at 15:38, Michael Gentry <mg...@masslight.net> wrote:
> 
> Hi Hugi,
> 
> Take a look at the model/code under here:
> 
> https://github.com/mrg/cbe/tree/master/InsertingObjects/MeaningfulPK
> 
> Essentially you map the meaningful key as a Java attribute and set the DB
> PK generation strategy to "Default" for those tables.  As long as you
> supply the meaningful PKs, Cayenne won't try to use the AUTO_PK_SUPPORT
> table that "Default" typically uses.
> 
> mrg
> 
> 
> 
> On Tue, Oct 18, 2016 at 11:27 AM, Hugi Thordarson <hu...@karlmenn.is> wrote:
> 
>> Hi all,
>> I’m currently working on a legacy DB where primary key values are both
>> meaningful and completely manually managed in code (no automatic PK
>> generation, sequences or anything, but have to be specified by the
>> programmer).
>> 
>> How do I tell Cayenne to not attempt to create PKs?
>> 
>> Cheers,
>> - hugi


Re: DB with totally manually managed primary keys

Posted by Michael Gentry <mg...@masslight.net>.
Hi Hugi,

Take a look at the model/code under here:

https://github.com/mrg/cbe/tree/master/InsertingObjects/MeaningfulPK

Essentially you map the meaningful key as a Java attribute and set the DB
PK generation strategy to "Default" for those tables.  As long as you
supply the meaningful PKs, Cayenne won't try to use the AUTO_PK_SUPPORT
table that "Default" typically uses.

mrg



On Tue, Oct 18, 2016 at 11:27 AM, Hugi Thordarson <hu...@karlmenn.is> wrote:

> Hi all,
> I’m currently working on a legacy DB where primary key values are both
> meaningful and completely manually managed in code (no automatic PK
> generation, sequences or anything, but have to be specified by the
> programmer).
>
> How do I tell Cayenne to not attempt to create PKs?
>
> Cheers,
> - hugi