-->
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.  [ 1 post ] 
Author Message
 Post subject: Using Hibernate to generate unique Id
PostPosted: Sun Jan 10, 2010 9:31 am 
Newbie

Joined: Wed Dec 09, 2009 11:20 am
Posts: 6
Hi all,

I am facing a problem related to Ids management. My problem is:

A has many B
I have a business key (B.key) in B which is a string equals to A.id + B.nb where nb starts from 1 and increment one by one. It means first B of A, second B of A...

I have problems creating B.id as I have problems incrementing B.nb. My problem is that I get max(B.nb) from DB and then add 1 but many times the latest B created was not yet flushed => I create many B with the same nb => the same B.key...

I am looking forward a solution to get a unique incemented nb from DB without flushing the entire object. Is it possible ? Can you give me examples of such a case ?

thanks a lot,
Charles


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.