-->
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
PostPosted: Wed Oct 12, 2005 10:47 am 
Newbie

Joined: Mon Sep 26, 2005 9:10 pm
Posts: 4
I need to have standalone ID generator which is not part of any table mapping. I need to write function which takes a sequence name as argument and returns the next val. what is the best way of doing this ?


Top
 Profile  
 
 Post subject: Re: ID generator
PostPosted: Wed Oct 12, 2005 10:55 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
devinenik wrote:
I need to have standalone ID generator which is not part of any table mapping. I need to write function which takes a sequence name as argument and returns the next val. what is the best way of doing this ?


Writing your own ID generator is pretty simple. You need to create a class that implements IdentifierGenerator. Inside this class you can do whatever you want to return the id.

Then in your mapping files, just specify your class as the <generator>

Code:
        <id name="id" column="MY_ID" type="long">
            <generator class="com.blah.blah.MyIdGenerator"/>
        </id>


You can look at the code for the standard implementations for examples.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.