Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354449 - HSQLDB support for IDENTITY columns doesn't work
Summary: HSQLDB support for IDENTITY columns doesn't work
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P2 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard: submitted_patch
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-10 19:07 EDT by David Green CLA
Modified: 2022-06-09 10:32 EDT (History)
1 user (show)

See Also:
tom.ware: iplog+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Green CLA 2011-08-10 19:07:41 EDT
HSQLPlatform incorrectly formulates HSQL IDENTITY clause as follows:

pre. 
GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1)

this results in the following error:

pre. 
Internal Exception: java.sql.SQLException: unexpected token: , required: )
Error Code: -5581

removing the comma after "START WITH 1" fixes the problem:

pre. 
GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1)

thus the HSQLPlatform class should be modified as follows:

bc. 
    @Override
    public void printFieldIdentityClause(Writer writer) throws ValidationException {
        try {
            writer.write(" GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1)");
        } catch (IOException ex) {
            throw ValidationException.fileError(ex);
        }
    }


related to task 240467 and task 297198
Comment 1 Tom Ware CLA 2011-08-11 09:08:23 EDT
Workaround is to subclass HSQLPlatform and provide the changed logic and then enable it in your persitence unit with the eclipselink.target-database persistence unit property.
Comment 2 David Green CLA 2011-08-11 18:22:39 EDT
(In reply to comment #1)
> Workaround is to subclass HSQLPlatform and provide the changed logic and then
> enable it in your persitence unit with the eclipselink.target-database
> persistence unit property.

Thanks Tom, that's what I did and it works for me.
Comment 3 Tom Ware CLA 2011-08-24 10:13:41 EDT
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 4 David Green CLA 2011-10-06 13:55:05 EDT
It's hard to believe that a fix as trivial as removing a single character (the comma) is worthy of voting.
Comment 5 Tom Ware CLA 2011-10-07 11:06:04 EDT
Strange...

From:

http://hsqldb.org/doc/guide/ch02.html

Under the heading "Identity Auto-Increment Columns"

"The supported form is(<colname> INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH n, [INCREMENT BY m])PRIMARY KEY, ...)."


The doc is claming a comma is correct.
Comment 6 Tom Ware CLA 2011-10-07 11:18:18 EDT
FYI: I am getting the same result as you when I actually create a table in the SQL console.
Comment 7 Tom Ware CLA 2011-10-07 11:18:41 EDT
I wonder if this is a bug in HSQL, or in the HSQL doc.
Comment 8 Tom Ware CLA 2011-10-07 11:40:55 EDT
Checked-in fix based on my experience of what works despite conflicting documentation.

Tested Manually

Review: Reviewed User-submitted fix
Comment 9 David Green CLA 2011-10-07 12:21:12 EDT
Thanks!
Comment 10 Eclipse Webmaster CLA 2022-06-09 10:32:33 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink