Well, it could be documented in the article on primary key generation ("for
performance reasons, Cayenne doesn't ask the DB for a new primary key every
time a record is inserted, but fetches primary keys in batches etc.…”). I’ll
write something up for the documentation and submit it. Shouldn’t modifications
to documentation be submitted as a pull request like everything else?
But even better would be if JdbcPkGenerator would warn the user if a DB
generated PK doesn’t match what it expects once the PK cache has been exhausted.
Cheers,
- hugi
> On 13. okt. 2015, at 14:04, Mike Kienenberger <[email protected]> wrote:
>
> I remember that happening to me way back in Cayenne 1.x when I
> converted over from EOF. I wonder if there's any way we can make
> this more obvious to the end-user who migrates from EOF? Hugi, was
> there any particular place where we could have documented this where
> it would have become obvious to you during the migration?
>
> On Tue, Oct 13, 2015 at 9:55 AM, Hugi Thordarson <[email protected]> wrote:
>> Thanks Michael, that was it. The sequences I was using were leftorvers from
>> EOF and were advancing by 1 at a time, while Cayenne expected 20. Now
>> everything works like a charm :).
>>
>> Cheers,
>> - hugi
>>
>>
>>
>>> On 13. okt. 2015, at 13:36, Michael Gentry <[email protected]> wrote:
>>>
>>> Hi Hugi,
>>>
>>> What are you using for PK generation? PostgreSQL's sequence generator
>>> should prevent duplicates. Make sure the number of keys it is allocating
>>> matches what Cayenne is using, though, otherwise you'll run into issues.
>>>
>>> mrg
>>>
>>>
>>> On Tue, Oct 13, 2015 at 5:38 AM, Hugi Thordarson <[email protected]> wrote:
>>>
>>>> Hi again all!
>>>>
>>>> I’m running into a problem where I’m getting duplicate primary keys in
>>>> Postgresql, i.e. records are getting the same primary key (when multiple
>>>> threads are writing to the same table). Any idea how I can prevent this? Do
>>>> I have to perform any manual synchronization?
>>>>
>>>> Cheers,
>>>> - hugi
>>>>
>>>> // Hugi Thordarson
>>>> // http://www.loftfar.is/
>>>> // s. 895-6688
>>>>
>>