I’m using hibernate to persist an entity to my database. For the moment it’s a derby DB, but I will be moving it over to an oracle DB soon.
in my classname.hbm.xml I have the id defined as such:
<id name="id" type="long">
<column name="ID"/>
<generator class="increment"/>
</id>
How do I set the starting value for the id? I’d like it to start at something like 10000 rather than 1.
I don’t think you can, it appears that IncrementGenerator works based off the highest primary key so unless you fix your primary keys (which I wouldn’t recommend) you’re stuck with that functionality.
Would recommend a different strategy, it isn’t safe in a cluster of machines either… Look at the Hibernate docs and maybe the enhanced identifier generators:
http://docs.jboss.org/hibernate/stable/core/reference/en/html/mapping.html#mapping-declaration-id-enhanced