Re: PK uniqueness
Re: PK uniqueness
- Subject: Re: PK uniqueness
- From: mailinglists via Webobjects-dev <email@hidden>
- Date: Tue, 16 Sep 2025 12:58:46 +0200
Standard PK generation is based on EOF keeping track of the last used value.
This last used value will always be counted up, never down. This insures that
no value will ever be re-used. The bookkeeping happens in two different ways,
depending on the database system. Many database systems provide some sort of
counter that only increments (usually called “sequence”). Typical examples are
Oracle and PostgreSQL. Accessing the “next value” is very fast and atomically
outside the current transaction. This may waste some values when a transaction
is rolled back. When the database system does not support sequences EOF uses a
dedicated table EO_PK_TABLE to keep track of the next value. Unless you
manipulate the sequences or the entries in EO_PK_TABLE manually you should not
have to worry about PK collisions at all.
In case you have non-EOF data inserts just make sure that the sequence or the
respective entry in EO_PK_TABLE is updated (manually).
---markus---
> On 15 Sep 2025, at 17:09, OCsite via Webobjects-dev
> <email@hidden> wrote:
>
> Hi there,
>
> presumed I use integer PKs and don't ever assign them myself, leaving it on
> EOF, can I rely on that never a newly created EO would get same PK as used to
> have one deleted previously? Or is there some rare scenario when this may
> happen?
>
> I need to store some information for EOs (which would be very rarely deleted,
> but occasionally it might happen) in a map whose keys would be the PKs (the
> map itself persists archived in a BLOB of another EO). I wonder whether I
> have to observe deletions and update these maps accordingly, or whether I can
> afford to simply keep PKs and information for deleted EOs in there without
> any real harm.
>
> Thanks!
> OC
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >PK uniqueness (From: OCsite via Webobjects-dev <email@hidden>) |