-->
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 Generate using function
PostPosted: Tue Jul 01, 2008 2:32 am 
Newbie

Joined: Tue Jun 17, 2008 11:01 pm
Posts: 16
Iam using a idgenerator class to generate id to the corresponding argument, That means this idgenerator class contains getNextid(String tableName) , The tableName argument may be "sales" or "purchase";
If we gave "sales" to getNextid it will return next value.

Table look like
idgenerator
id table_name value

1 sales 12
2 purchase 5

So if we call getNextid with "sales" argument it will return 13, i think u got the idea.

I need to used it in hibernate mapping file (sales.hbm.xml)'s <id> section

Wow can i do this ? which generator is used for that ? please give me some advice .. thanks to all[/list]


Top
 Profile  
 
 Post subject: Re: ID Generate using function
PostPosted: Tue Jul 01, 2008 4:35 am 
Newbie

Joined: Mon Jun 05, 2006 12:41 pm
Posts: 19
anishanc wrote:
Iam using a idgenerator class to generate id to the corresponding argument, That means this idgenerator class contains getNextid(String tableName) , The tableName argument may be "sales" or "purchase";
If we gave "sales" to getNextid it will return next value.

Table look like
idgenerator
id table_name value

1 sales 12
2 purchase 5

So if we call getNextid with "sales" argument it will return 13, i think u got the idea.

I need to used it in hibernate mapping file (sales.hbm.xml)'s <id> section

Wow can i do this ? which generator is used for that ? please give me some advice .. thanks to all[/list]


I think there is something in the doc about this :
Code:
<id name="id" type="long" column="cat_id">
<generator class="org.hibernate.id.TableHiLoGenerator">
<param name="table">uid_table</param>
<param name="column">next_hi_value_column</param>
</generator>
</id>


Your class generating codes have to implement org.hibernate.id.IdentifierGenerator. So you can use it after in the mapping...


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.