-->
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: Writing my own generator
PostPosted: Fri Aug 26, 2005 7:05 am 
Newbie

Joined: Fri Apr 01, 2005 2:15 am
Posts: 14
Hi all,
In my application the primary key(varchar2) of a table is like"student123",where student is same but 123 is following a sequence for each new row.For example the primary key of the next row will be "student125" and so on. How should I write my generator class to yeild such value.Please give some suggestions.

With regards,
Ajse


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 26, 2005 9:00 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Extend AbstractPostInsertGenerator.

Use extra table to generate you sequence numbers - 123, 124, ...
When inserting into table set trigger to also insert something into sequence generator table. Then simply pull that last sequence generated number out and concatenate it with your 'student' string.

But there are many options. Just look at the IdentifierGenerator and its implementations for some idea.


Top
 Profile  
 
 Post subject: custom identifier generator
PostPosted: Mon Sep 12, 2005 8:07 am 
Newbie

Joined: Fri Apr 01, 2005 2:15 am
Posts: 14
Hi all,
I am not understanding the hibernate source code.Can anybody please provide some help or suggest some tutorial on how should I write my own custom id generator?I will be thankful.
with regards,
ajse


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.