|Context-sensitive composite primary keys [message #1201188]
||Thu, 21 November 2013 16:16
| Jürgen Krey
Registered: July 2009
I am looking for support for generating a special kind composite primary keys.|
The general table design assumes that all tables use logical PKs, ie. there are mostly strings concatenated with consecutive number, eg. "ORDER1", "ORDER2", .. for order entities.
The difficult part is when it comes to relations:
the primary key of an "order item" entity is composed of
the primary of the reeferenced order entity and another consecutive number, ie.
- Order Item 1 has PK ("ORDER1", 1)
- Order Item 2 has PK ("ORDER1", 2) and so on.
If I want to generate composite primary keys for order items, i have to
find the maximum pk index of "ORDER1" order items and increment by '1'.
This is a kind of "context-sensitive" sequence generator, because it might
need the context of tzhe referenced entity, at least if i need strictly consecutive numbers:-(
Even worse: Connecting two entities means, that key generation
for newly created JPA entities must be finished before the objects can be connected.
This looks pretty much like a 2 phase approach.
Do you any eclipseLink extension for my composite key generation problem?
Powered by FUDForum
. Page generated in 0.02519 seconds