-->
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.  [ 5 posts ] 
Author Message
 Post subject: Key generator advice needed
PostPosted: Mon Jul 25, 2005 2:35 am 
Regular
Regular

Joined: Thu Nov 20, 2003 10:04 pm
Posts: 64
Location: Melbourne, Australia
Hibernate version:

2.x

Name and version of the database you are using:

SQL Server
HSQLDB
Oracle

My application is built to support multiple databases. To date I've used a TableHiLoGenerator to generate my keys. As I also need to be able to support bulk inserts this is becoming increasingly undesireable.

I'd switch to sequences but then sql server doesn't support them. I'd switch to an autoincrement column but oracle doesn't support those! Is there any alternative id generation technique that will work well for bulk inserts? Would it be possible to create a custom generate that swaps implementations depending on the dialect?

Regards,

Glen


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 25, 2005 2:56 am 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
hmmm ... i don't know if it helps you ...

But perhaps provide your own dialects and an own IdentifierGenerator could be a possibility?
In your Generator you could do something like
Code:
if ( ((myDialect)dialect).getDatabase() == MyDialect.ORACLE)
  ...
else
  ...


In your Generator you could use the built-in-hibernate-generators like used in "IdentifierGeneratorFactory.create".

Like i said ...don't know if it helps you, just a "fast idea" :)

gtx
curio (don't know really much about oracle but wondering that oracle doesn't support autoincrement-fields)

BTW.: For me, not really nice, but possible is to use a sequence and trigger to simulate "autoincrement fields".


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 25, 2005 3:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Why not just use "native"??


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 25, 2005 3:26 am 
Regular
Regular

Joined: Thu Nov 20, 2003 10:04 pm
Posts: 64
Location: Melbourne, Australia
gavin wrote:
Why not just use "native"??


I had it in my mind that native was something else entirely but that sounds like it would work just fine.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 25, 2005 3:42 am 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
sorry!! i've forgotten the simplest way ... :(

In my situtation one db doesn't support neither "identitycoloums" nor "sequences" and "TableHiLo" shouldn't be used because connections are fetched from an application server datasource. Therefore i've simply forgot "native" ... sorry!

gtx
curio


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