På fredag 05. juli 2013 kl. 09:51:03, skrev Tom Dunstan <pgsql@tomd.cc>:
On 9 February 2013 02:56, Kris Jurka <books@ejurka.com> wrote:
The other workaround is to use the url parameter stringtype=unspecified to
have setString always bind to unknown instead of varchar, which then
shouldn't require any code changes.
 
I just tried this with a new project using hibernate and postgres with an enum type . Unfortunately, the hibernate (3.6) enum type calls setObject(pos, value, Types.VARCHAR) rather than calling setString(pos, value), and that doesn't respect the stringtype property.
 
What's the feeling here - should setObject(Types.VARCHAR) respect stringtype=unspecified? I don't know whether there are semantic differences between setString() and setObject(Types.VARCHAR) to know if that's naughty or not. It seems like the only way for me to use this version of hibernate with pgsql enums is to either change the driver or implement a custom user type and configure it everywhere. :(
 
Happy to whip up a patch if there's consensus to change the driver.
 
Cheers
 
Tom
 
I've been using Hibernate for years with mapping Enums to varchar-columns which works fine. Remember to map them with
 
@Column(name = "column_name")
@Enumerated(EnumType.STRING)
private MyEnum enum = <stuff>
 
--
Andreas Joseph Krogh <andreak@officenet.no>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc