Set primary key on hibernate generated sequence table
Posted
by bungrudi
on Stack Overflow
See other posts from Stack Overflow
or by bungrudi
Published on 2010-04-28T03:19:12Z
Indexed on
2010/04/28
3:23 UTC
Read the original article
Hit count: 184
setup: hibernate 3.3, MySQL 5
I have an hibernate entity that have its PK generated using a sequence table. The annotation looks like this:
@GenericGenerator(name = "SCENARIO_TABLE_GEN", strategy = "org.hibernate.id.enhanced.TableGenerator", parameters = { @Parameter(name = "initial_value", value = "5"), @Parameter(name = "force_table_use", value = "true"), @Parameter(name = "table_name", value = "SEQ_TABLE"), @Parameter(name = "value_column_name", value = "VALUE_COL"), @Parameter(name = "segment_column_name", value = "KEY_COL"), @Parameter(name = "segment_value", value = "SCENARIO") })
The problem is, that hibernate generated sequence table (SEQ_TABLE in my case, generated using hbm2ddl) does not have a primary keys.
How do I tell hibernate that I want to have the primary key for the sequence table set on KEY_COL ?
© Stack Overflow or respective owner