Change automatical primary key sequence
724181Nov 10 2009 — edited Nov 23 2009Hi.
I'm using the Berkeley 3.3.75 DB DPL. I have a MetaClass that all objects share which holds among others the primary key. The key is defined with a named Sequence to make it auto incremental. From my understanding, that was supposed to ensure me that the database consisted of unique id's. I must have misunderstood, because as it turns out, that is not the case.
What I would like to do is to keep the auto incrementation part, but add a class signature to the key to make it unique (mind you, in order to make it unique across stores, I need to add a store signature as well).
The way I figure, I've got three options:
1. Find a way to interfere with the sequence and add my class signature to it at "put()"
2. manually set up my own automatic id increment and set it to an object just before calling put.
3. setting up a composite key consisting of the key I've already used and the signature. This option is only relevant if there is a way to increment one of the KeyField's in the composite key. Otherwise I'm back to option 2.
The only option that I know is possible and I know how to do is option 2. Best option would be using the composite key, among others because it adds some transparency to my magic class signature. However, it would require a quite a bit of refactoring.
I was hoping I could get some help on figuring out what options are possible and what option is better.
Hope to hear from you guys. Thanks
--Martin