-->
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.  [ 2 posts ] 
Author Message
 Post subject: Id generator question
PostPosted: Sun Oct 12, 2003 2:18 pm 
Beginner
Beginner

Joined: Sun Oct 12, 2003 2:14 pm
Posts: 25
Location: Zagreb, Croatia
I want to use "distributed" database, what I want is to add to every generated table ID unique suffix, unique for every database server. To have keys on one server:

00001001
00002001
00003001

Should I write my own implementation of interface net.sf.hibernate.id.IdentifierGenerator or should I use some of provided generators?[/list]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 13, 2003 2:33 am 
Senior
Senior

Joined: Tue Sep 23, 2003 8:18 am
Posts: 137
Location: Johannesburg, South Africa
Looking at what Hibernate has available, and that I doubt it can (or even should) allow for multiple database ID generation using a SEQ type ID.

I'd go with creating your own generator class that uses the same principle as the SEQUENCE generator. I'm guessing that the first bit (00001 - 00003) is going to be unique? And that you only append the (001) to the end each time?

Then, change you Hibernate mapping to use an ASSIGNED ID. That way, you run you can still use sequence - just do that query manually (can use Hibernate to do this bit too) - and create the PK, which you then assign to your mapping.

-G


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