-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Start value for ID generation
PostPosted: Tue Mar 01, 2005 6:45 pm 
Newbie

Joined: Tue Mar 01, 2005 6:20 pm
Posts: 2
We're about to go live with our website but don't want to expose our users to id's in the low digits. Seeing UserId:3 on a page just doesn't look good or even professional. So have embarked on finding out how to set a start value for entity Id's.

We're using mysql 4.1.7 with innodb tables and hibernate 3. All of our entities are mapped with the following:

Code:
<id name="id" type="long"><generator class="native"/></id>


Now as far as I can tell from the mysql and innodb manuals, and from the hibernate website and book the only way to do this is to insert a record with a given id, say 18274128 and then delete that record.
http://dev.mysql.com/doc/mysql/en/innod ... olumn.html

I've actually tried this with our setup on a couple of tables and it only seems to work from the mysql shell and not from hibernate itself, even using straight sql on the jdbc connection, and even using explicit delete from foo where id= statements, and finally even tried creating the records and rolling back the tx.

What would be superb is:
Code:
<id name="id" startval="72382387"...

or as a parameter to a generator. Does anyone else see a need for this?

Initializing the start values on all of our tables via a script seems just plain ugly. Any fresh ideas greatly appreciated.

Dumitrius


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 8:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I think there is a way to specify the autoincrement start value when creating the table ... check the mysql manual


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 01, 2005 8:55 pm 
Newbie

Joined: Tue Mar 01, 2005 6:20 pm
Posts: 2
michael wrote:
I think there is a way to specify the autoincrement start value when creating the table ... check the mysql manual

Thanks, yes that should work. In our case though we're relying on hibernate's schema export function. Yes, could easily switch to using scripts but then there's one more thing to maintain whenever there's a schema change (though once we're live this will be a moot point). I do still maintain that this would be a useful feature, probably implemented as a generator param, or? Yeah can probably implement or extend a generator though was looking for an easier way out =)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.