H2 database column name “GROUP” is a reserved word

后端 未结 3 884
闹比i
闹比i 2020-12-02 02:05

How do I create a table in H2 with a column named GROUP? I saw an example that used something like [*] a while ago, but I can\'t seem to find it.

3条回答
  •  死守一世寂寞
    2020-12-02 02:32

    I've been having this problem with SQL generated by JPA... Turned out I was using a variable name called limit.

    Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "CREATE TABLE EXPENSE_LIMIT (ID BIGINT NOT NULL, LIMIT[*] DECIMAL(19,2), ACCOUNT_ID BIGINT, EXPENSE_CATEGORY_ID BIGINT, PERIOD_ID BIGINT, PRIMARY KEY (ID)) "; expected "identifier"; SQL statement:
    

    Where my model class had a field called limit.

    The fix is to specify column name as

    @Column(name = "`limit`")
    

提交回复
热议问题