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
|