-->
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.  [ 4 posts ] 
Author Message
 Post subject: id generation with hiberante and non hibernate processes
PostPosted: Mon May 28, 2007 9:17 am 
Beginner
Beginner

Joined: Thu May 10, 2007 4:20 am
Posts: 27
Hello,

Till recently I've been using successfully the org.hibernate.id.enhanced.TableGenerator id generator, but now I came across an interesting problem:

I have a table that both hibernate and non-hibernate processes access and insert new rows into, possibly simultaneously.
Therefore I no longer can use the sequence approach, as the non-hibernate process is not aware of the sequence-like table used by hibernate, and does not increment the appropriate value.

Neither can I use the increment generator, as it is not protected against simultaneous access.

The hi/lo generator is as well unsuitable, if I understand correctly, as the non-hibernate process will not use it, therefore the generator might return already used value.

Therefore, the only solution that I see is to implement my own indicator, or have I missed anything?

Any help is highly appreciated,
Vitaliy


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 28, 2007 8:53 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
No. As your your options are dependent on what controls you have over the other processes insert operations into the DB.


Top
 Profile  
 
 Post subject: And what about locking?
PostPosted: Tue May 29, 2007 4:15 am 
Beginner
Beginner

Joined: Thu May 10, 2007 4:20 am
Posts: 27
Therefore I need to implement locking mechanisms as well?
Lets say that I'll write a class that would implement id generation.

So, I'll have to lock the table for inserts from the moment that I've generated the id, till the moment that the object had actually been flushed into the database by hibernate (otherwise the id generated might not be unique - as it might have been already used by some other non hibernate process which uses some different id generation strategy in the time between the generation and the actual insert).

How can I minimize this time, and also know when the flush had actually occurred? I would like not to use database triggers, as they are database dependent?

Thanks allot,
Vitaliy


Top
 Profile  
 
 Post subject: Did I forget to add any details?
PostPosted: Wed May 30, 2007 3:37 am 
Beginner
Beginner

Joined: Thu May 10, 2007 4:20 am
Posts: 27
Are any other details requiered?

Thanks,
Vitaliy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.