Hi,
this time I have a really tricky one.
I need to use an existing DB2Sequence of an existing table for the primary key of a newly added table.
When Glorp creates the table (in #createTables:) it always assumes there is a strict 1:1 relationship between tables and sequences, so it tries to create a sequence for the new table. Creating the same sequence twice, however, is not accepted by the database ;-)
Background:
I have a class that has existed for a while. Now I want to add a new class that is the existing class's sibling (they both subclass a common superclass). The new class has loads of additional attributes, so there is no way of using a FilteredTypeResolver (both classes in one table).
So I wanted to use a HorizontalTypeResolver. This, however, requires the two mapped classes to share a sequence, so that the ids of the two tables don't overlap.
And this is where I got lost: I cannot find a way to tell a field to be a "platform sequence" which re-uses the native db sequence of another table.
Here's what I tried:
tableForMYTABLE: aTable
(aTable createFieldNamed: 'id' type: (self sequenceTypeNamed: 'ExistingTable_id_seq'))
bePrimaryKey.
This leads to a "duplicate name" sql exception when I create the table.
So I am lost.
Is there some other way to have two tables share a sequence that is auto-generated by the database? It seems all of Glorp's Sequence classes that sound as if they could help me are not finished, there are lots of subclassResponsibilities that are not implemented on these subclasses.
has anybody done this before?
Joachim