[hibernate-dev] IdentifierGenerator, which *may* implement PostInsertIdentifierGenerator

Jochen Wiedmann jochen.wiedmann at gmail.com
Fri Dec 4 02:50:04 EST 2009


Hi,

for some particular project, I'd like to have a custom
IdentifierGenerator, which could be thought of as an extension of the
"native" IdentifierGenerator. Basically, it ought to take the id
generated by the "native" generator, but then do some magic with it,
for example add a prefix. (Yes, I know, don't push me on that, I have
already lost my struggle against a "telling ID".)

Such an IdGenerator is easily implemented: Create a class, which
queries the IdentifierGeneratorFactory for the "native"
IdentifierGenerator and use that. (Works fine.)

The problem is, that the "native" generator is sometimes implementing
PostInsertIdentifierGenerator. Of course, I can have my generator
implement PostInsertIdentifierGenerator as well, but that means that
it will break on systems without a sequence. OTOH, I can remove the
interface, but then it won't work on the other systems.

An alternative might be, to add a new "myNative" term to the
IdentifierGeneratorFactory, but that class neither allows extension
(it's final, for whatever reason) nor does it support extending the
map of builtin types.

Any ideas?

Thanks,

Jochen


-- 
Germanys national anthem is the most boring in the world - how telling!



More information about the hibernate-dev mailing list