-->
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: Questions about hibernate key generator
PostPosted: Fri Mar 19, 2004 7:47 pm 
Newbie

Joined: Fri Mar 19, 2004 7:12 pm
Posts: 3
How can I determine the next available key for a table, according to hibernate's key generator? I want to get at this data for some direct JDBC inserts. It seems trivial if I implement my own custom key generator, but I'd prefer not to have to do that. I'm using the id generator "sequence" (at least I'm pretty sure, I'm actually using "native" with McKoi) and would like to leverage that for JDBC inserts if possible.

A related question: I execute some SQL to initialize my database before the app runs for the first time, and I rely on some McKoi table sequences for id generation, but this conflicts with hibernate's key generation. In other words, I need to set up some default entries in table X, and within the app the user can create some entries in X, but the first few tries the user will get primary key conflicts with my default entries (until the hibernate keygen sequence makes it past my table sequence). Is there an easy way around this? One solution is to insert that data via hibernate the first time the application runs, but that requries quite a few changes. Any other options?

Also, if this is easier to handle with another DB, let me know. I'm considering moving away from McKoi.

-Adam


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 24, 2004 6:54 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Have a look at the src package hibernate.id, you'll find some reusable code.

If you use the same sequence, then the id should not be the same !

_________________
Emmanuel


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.