I'm using JPA Annotations with Hibernate backed by a PostGreSQL database. I've been generally quite happy with how cleanly everything works, but I've had a few complaints over how @GeneratedValue interacts with the rest of the system.
Currently I have to do something like:
Now I know I can configure a NamingStrategy to handling Competition<->competitions mapping and I'm not concerned about that. However the verboseness of making a GeneratedValue read from a normally named PostGreSQL sequence is annoying.
I would rather be able to use only @GeneratedValue, ie the "Native" generator type, which would resolve back to a sequence under PostGreSQL. Unfortunately it defaults to a single, shared-across the entire database, sequence, not a per table sequence. Thus I need to provide explicitly for a) the name of the sequence via a @SequenceGenerator and b) for the entity to use a generator...
I'm not too happy with this from a portability stand-point (but I don't anticipate leaving PostGreSQL) and I'm not happy with the wordiness.
There's no place in a NamingStrategy, that I could find at least, for providing to override the sequence name used by Native.
Has anyone else run across this? Is there a good solution?
(If I could get hbm2ddl to work, perhaps I wouldn't care as much, but at present I'm tending to create the database first and definitely like being able to use PostGreSQL "serial" type for now....)
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads