-->
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: Generating ad-hoc, non-pk sequenced values in DB2+hibernate
PostPosted: Thu Jul 22, 2004 6:42 am 
Newbie

Joined: Thu Jul 22, 2004 6:32 am
Posts: 1
We need to generate sequenced keys that ARE NOT the primary key and are generated at some time (maybe days, weeks, who knows when) after the record itself has been saved.

The most effective and safest way we can think to do this in DB2 is to use a sequence. However, we still want to maintain some kind of encapuslation of configuration using hibernate.

We could:

* Get a connection and do our own hand-crufted SQL in code;

* Define some sql-queries, call session.getQueryByName() and execute it directly as SQL;

* Create a SequenceGenerator and use it directly;

* Map some BS classes with ids mapped to the appropriate sequence, find a persister and ask it to generate an id;

* etc..

Given the myriad possible ways to do this (all of which seem pretty disgusting IMHO), which one would they that know best, suggest?

This is the first time I've every needed to do anything remotely like this with hibernate but I'm sure someone out there has some thoughts on the subject.

Cheers,

Simon


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.