Tom Dunstan <pgsql@tomd.cc> writes:
> ... That works ok, but when attempting to use a prepared statement:
> ps = con.prepareStatement("insert into enumcast values (?)");
> ps.setString(1, "meh");
> ps.executeUpdate();
> we get a
> org.postgresql.util.PSQLException: ERROR: column "current_mood" is of
> type mood but expression is of type character varying
> Hint: You will need to rewrite or cast the expression.
AFAIK this is just business as usual with JDBC: setString() implies that
the parameter is of a string type. It'll fall over if the type actually
required is anything but a string. (I'm no Java expert, but I seem to
recall that using setObject instead is the standard workaround.)
Enums are not suffering any special hardship here, and I'd be against
weakening the type system to give them a special pass.
regards, tom lane