How to reserve a set of primary key identifiers for preloading bootstrap data

Posted by Joshua on Stack Overflow See other posts from Stack Overflow or by Joshua
Published on 2010-04-09T09:10:14Z Indexed on 2010/04/09 9:13 UTC
Read the original article Hit count: 403

Filed under:
|
|
|

We would like to reserve a set of primary key identifiers for all tables (e.g. 1-1000) so that we can bootstrap the system with pre-loaded system data.

All our JPA entity classes have the following definition for the primary key.

@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false, insertable = false, updatable = false)
private Integer id;

is there a way to tell the database that increments should start happening from 1000 (i.e. customer specific data will start from 1000 onwards). We support (h2, mysql, postgres) in our environment and I would prefer a solution which can be driven via JPA and reverse engineering DDL tools from Hibernate.

Let me know if this is the correct approach

© Stack Overflow or respective owner

Related posts about jpa

Related posts about hibernate