Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Derby Identity column DDL and SQL insert scripts #78

Closed
eharrow opened this Issue · 2 comments

3 participants

@eharrow

Using Derby and have hit an issue when running some SQL scripts to
insert data into a fresh mapper DB created by schemifier.
Specifically when inserting records with the id column I get a
violation:

Error: Attempt to modify an identity column 'ID'.
SQLState: 42Z23
ErrorCode: -1

i.e data can't be inserted into this column which is not helpful when
this id is the primary key and foreign key on another table. Derby
does support auto-incremented sequence values as default only when
you are not providing values as opposed to always providing auto-
incremented sequence values which you are not allowed to specify your
own values. The difference is GENERATED BY DEFAULT AS IDENTITY
instead of GENERATED ALWAYS AS IDENTITY.

To this end it looks like net.liftweb.mapper.DerbyDriver.scala needs
updating from
def integerIndexColumnType = "INTEGER NOT NULL GENERATED ALWAYS AS
IDENTITY"
def longIndexColumnType = "BIGINT NOT NULL GENERATED ALWAYS AS
IDENTITY"

to
def integerIndexColumnType = "INTEGER NOT NULL GENERATED BY DEFAULT
AS IDENITY"
def longIndexColumnType = "BIGINT NOT NULL GENERATED BY DEFAULT AS
IDENTITY"

Hope this helps

-- Ewan

@dpp dpp was assigned
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.