-->
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: How to generate custom Id using the sequence. eg: S121
PostPosted: Mon Jun 27, 2005 2:24 pm 
Newbie

Joined: Mon Jun 27, 2005 2:11 pm
Posts: 2
Mapping documents:

Hello,

I am trying to generate a custom Id using the oracle sequence.

This is what I want to do. I want to generate a custom Id which is like "S101", here I will get the value "101" from the sequence. I need to append a character "S" to that value, is there any way I can accomplish this? Can I write custom generator class and if so how? Thanks for your time

Thomas


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 8:45 am 
Regular
Regular

Joined: Thu Apr 29, 2004 5:08 pm
Posts: 56
Location: Montreal, Quebec, Canada
I don't think you can do that. If you want the database to generate the id, well, the database generates it and you have no control over it. Also, a sequence is a number. By putting a letter in front of it you change its type. Maybe oracle let you tweak id generation, maybe you could perform the necessary select to get the next sequence from oracle and use it to form your final id. You would then use the "assigned" generator. However, I'm not sure you can ask Oracle to give you a new id, normally, you perform an insert and you get the generated id afterward.

_________________
- Frank


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 28, 2005 9:15 am 
Newbie

Joined: Mon Jun 27, 2005 2:11 pm
Posts: 2
fdelisle:

I solved the problem as described in http://forum.hibernate.org/viewtopic.php?t=929341

Thanks for you time. I created the custom class to generate the id by implementing net.sf.hibernate.id.Configurable and net.sf.hibernate.id.PersistentIdentifierGenerator

Thanks for your time


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.