开发者

Specify initial value of HSQLDB identity via annotation

Can I specify the initial value for an IDENTITY column using Hibernate/JPA annotations on top of an HSQLDB database? The relevant source code looks like this so far:

@Id
@G开发者_运维百科eneratedValue(strategy=GenerationType.AUTO)
public Long getId() {
    return id;
}

The generated DDL looks like this:

id bigint generated by default as identity (start with 1)

What I'd like to do is make the ID start with a value of 10,000 via annotations.

Note: This is a new application so I'm using the latest versions of Hibernate and HSQLDB.


As this question was not initially tagged as Hibernate, it was probably missed by Hibernate experts. I just noticed the Hibernate HSQLDialect returns the (start with 1) for all identity creation. Therefore there is probably no way to override this.

You should be looking into how to execute an SQL statement to reset the identity AFTER the table is created but before data is added. The SQL looks like:

ALTER TABLE hibernate_generated_table_name ALTER COLUMN id RESTART WITH 10000
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜