-->
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.  [ 8 posts ] 
Author Message
 Post subject: higher value
PostPosted: Mon Jan 12, 2004 7:39 pm 
Regular
Regular

Joined: Thu Dec 25, 2003 12:33 am
Posts: 58
Location: Campina Grande, Brasil
I'm using the "native" method to generate my table id's. Before having my values set in the database (so, before having my id value set in the db), i need to get this value, so i can generate another controller (based on the current date and id) value which is going to be stored in another column. Are there hibernate ways to do it? what is the best one?

Thanks

_________________
Ot


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 12, 2004 7:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No. It is technically impossible to get the next id in many cases, for example if using auto-increment on mysql.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 12, 2004 7:58 pm 
Regular
Regular

Joined: Thu Dec 25, 2003 12:33 am
Posts: 58
Location: Campina Grande, Brasil
Is there a way to start generating the id not from 1, but from a number i specify?

_________________
Ot


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 12, 2004 7:59 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Depends on the generator and your database.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 12, 2004 8:05 pm 
Regular
Regular

Joined: Thu Dec 25, 2003 12:33 am
Posts: 58
Location: Campina Grande, Brasil
it is mysql, and i want to increment of 1. So, I'm using the native method in the hibernate mapping file. Ok, all works fine. But I'd like the first generated id not to be "1", but to be another value (any value), and increment of 1 after this value for the rest of the values.

_________________
Ot


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 12, 2004 8:13 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You can set the starting value of autoincrement when creating the tables, I think by doing something like this:

Code:
CREATE TABLE (
    ....
) AUTO_INCREMENT 15


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 12, 2004 8:17 pm 
Regular
Regular

Joined: Thu Dec 25, 2003 12:33 am
Posts: 58
Location: Campina Grande, Brasil
is there a way to do it in the mapping file?

_________________
Ot


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 12, 2004 8:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
no


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.