-->
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.  [ 7 posts ] 
Author Message
 Post subject: ID Generating !
PostPosted: Mon Aug 22, 2005 3:28 am 
Newbie

Joined: Mon Aug 22, 2005 3:13 am
Posts: 3
Hi.

first of all i wanna thank all you guys .
Hibernate is perfect. :)

my problem :( :
i am new to hibernate and wanna implement a
"20-bit" ID Generator.
I am using MySQL as a Database.

i dont know how :(
is there any common algorithm ?
is there any generator ?

it seems too dificult to me.

i ll be thankful if u help me.

[/i]


Top
 Profile  
 
 Post subject: Re: ID Generating !
PostPosted: Mon Aug 22, 2005 4:23 am 
Newbie

Joined: Mon Aug 22, 2005 3:13 am
Posts: 3
hesam wrote:
Hi.

first of all i wanna thank all you guys .
Hibernate is perfect. :)

my problem :( :
i am new to hibernate and wanna implement a
"20-bit" ID Generator.
I am using MySQL as a Database.

i dont know how :(
is there any common algorithm ?
is there any generator ?

it seems too dificult to me.

i ll be thankful if u help me.

[/i]


What's a problem if i substring GUID to generate 20 char ID ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 22, 2005 5:00 am 
Senior
Senior

Joined: Thu Aug 04, 2005 4:54 am
Posts: 153
Location: Birmingham, UK
If you need really need a custom ID generator then implement IdentifierGenerator and write your own generator.

See the files in org.hibernate.id for more information.


Top
 Profile  
 
 Post subject: Re: ID Generating !
PostPosted: Mon Aug 22, 2005 11:00 am 
Senior
Senior

Joined: Tue Aug 03, 2004 2:11 pm
Posts: 142
Location: Somerset
my problem :( :
i am new to hibernate and wanna implement a
"20-bit" ID Generator.
I am using MySQL as a Database.

[/i][/quote]

Why don't you let mySQL generate it using an identity column ?

_________________
On the information super B road


Top
 Profile  
 
 Post subject: Re: ID Generating !
PostPosted: Mon Aug 22, 2005 12:16 pm 
Newbie

Joined: Mon Aug 22, 2005 3:13 am
Posts: 3
Paul Newport wrote:
my problem :( :
i am new to hibernate and wanna implement a
"20-bit" ID Generator.
I am using MySQL as a Database.

[/i]


Why don't you let mySQL generate it using an identity column ?[/quote]

would you tell more about identity column .
can i have unique ID with lenght of 20 with that?
its length is very important to me .

and about GUID i found out that it's sortable and i think substring of that
cant make a Duplicate Key trouble.

by the way i have not large amount of data max, 1,000,000


thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 22, 2005 12:22 pm 
Senior
Senior

Joined: Thu Aug 04, 2005 4:54 am
Posts: 153
Location: Birmingham, UK
Link to the page in the MySQL documentation that explains it.

http://dev.mysql.com/doc/maxdb/en/6d/11 ... ameset.htm


Top
 Profile  
 
 Post subject: Re: ID Generating !
PostPosted: Mon Aug 22, 2005 3:04 pm 
Senior
Senior

Joined: Tue Aug 03, 2004 2:11 pm
Posts: 142
Location: Somerset
Can you explain why you want to manage the surrogate key yourself ?

Surrogate keys should be inheritently meaningless, and if the database can generate them all the better, as you don't need to worry about it.

If the database supports surrogate key generation natively as in an identity column, why not let the database handle it and get on with the important stuff, the application code ?

_________________
On the information super B road


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.