Hibernate won't autogenerate sequence table

Posted by Jason on Stack Overflow See other posts from Stack Overflow or by Jason
Published on 2010-04-15T23:31:19Z Indexed on 2010/04/15 23:33 UTC
Read the original article Hit count: 133

Filed under:

I'm trying to use a sequence table to generate keys for my entities. I notice that if I just use the @GeneratedValue(strategy=GenerationType.TABLE) with no explicit generator, Hibernate will automatically create the hibernate_sequences table in my DB if it doesn't exist. This is great. However, I wanted to make some changes to the sequence table, so I created a @TableGenerator like the following:

@GeneratedValue(strategy=GenerationType.TABLE, generator="vdat_seq")
@TableGenerator(name="vdat_seq", table="VDAT_SEQ", pkColumnName="seq_name",
    valueColumnName="seq_next_val", allocationSize=1)

This works fine if I manually create the VDAT_SEQ table in my schema; Hibernate won't auto-create it anymore. This causes an issue in my unit tests, since I'd rather not have to manually create a table and maintain it on our testing DB.

Is there a configuration variable or some other way to get Hibernate to generate the sequence table?

© Stack Overflow or respective owner

Related posts about hibernate