AutoIncrementSequenceFactory.

Hi,
I am trying to use the AutoIncrementSequenceFactory with sql server.
When I try to insert an object into the table the database complains that
there are null values.
I assume this is due to the fact that kodo executes
INSERT INTO table DEFAULT_VALUES;
The default value is null, and the table does not allow nulls. I cannot
change our validation rules and allow null values just so that auto
increment keys work.
Please help.
Regards
Craig.

Craig,
The way we handle auto-incrementing columns (IDENTITY columns in
SQLServer-speak) is to insert a placeholder row into the database, obtain
the ID value that was inserted, and delete the row from the database. We
then use the retrieved ID later when we insert the proper data into the
database.
So, by default, for SQLServer, we just use default values for the table.
You can get around this by extending our SQLServerDictionary and
overriding the behavior of the getAutoIncrementValue() method to do
something other than what we do.
In the future, we may add a mechanism to control some of this behavior
from the class's XML metadata file. But in the mean time, you'll have to
just encode the appropriate logic that special-cases those tables for
which you can't use default values into the dictionary yourself.
-Patrick
On Sun, 18 May 2003 06:17:53 -0400, Craig Main wrote:
Hi,
I am trying to use the AutoIncrementSequenceFactory with sql server.
When I try to insert an object into the table the database complains
that there are null values.
I assume this is due to the fact that kodo executes INSERT INTO table
DEFAULT_VALUES;
The default value is null, and the table does not allow nulls. I cannot
change our validation rules and allow null values just so that auto
increment keys work.
Please help.
Regards
Craig.--
Patrick Linskey
SolarMetric Inc.

Similar Messages

Maybe you are looking for