You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-dev@db.apache.org by Craig L Russell <Cr...@Sun.COM> on 2006/03/28 00:16:04 UTC
Datastore identity strategy
Javadogs,
I took an action item to resolve whether the TCK needs different
metadata files to describe the different strategies that databases
use for generating primary key values.
The spec says,
<spec>
•The value “sequence” specifies that a named database sequence is
used to
generate key values for the table. If sequence is used, then the
sequence
attribute is required.
•The value “identity” specifies that the column identified as the key
column is
managed by the database as an identity type.
</spec>
In the TCK, we only use strategy="identity" and the issue is whether
databases that don't support the SQL 2003 construction "GENERATED
ALWAYS AS IDENTITY" can use this same strategy.
My reading of the specification is that the identity strategy can be
used for any database as long as the database is configured to
generate the keys. Such constructions as PostgreSQL SERIAL and Oracle
sequences can be used, meaning that the SQL for the table declares
that the database, not the JDO implementation, is responsible for
generating the keys.
The effect of this interpretation is that the TCK is valid for all
databases that are capable of generating the primary key values
(which I think is all databases of interest to us).
Therefore, there is no need to change the TCK to accommodate
databases that don't support the "GENERATED ALWAYS AS IDENTITY". A
suitable SQL table definition can be used for all databases to
implement the identity strategy.
I propose that we clarify this with a change to the specification,
<proposed>
•The value “sequence” specifies that a named database sequence is
used to generate key values for the table. If sequence is used, then
the sequence attribute is required. The JDO implementation uses the
named sequence in insert statements for the table.
•The value “identity” specifies that the column identified as the key
column is managed by the database as an identity type, regardless of
how the database generates the values, e.g. using the SQL 2003
IDENTITY column type or using triggers and stored procedures with a
sequence. The JDO implementation does not provide primary key values
for the table.
</proposed>
I'm also trying to figure out if we need the following:
<spec>
•The value “autoassign” specifies that the column identified as the
key column
is managed by the database to automatically increment key values.
</spec>
Would anyone notice if we removed this?
Craig
Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!