Re: [JDBC] JPA + enum == Exception
| От | Tom Lane |
|---|---|
| Тема | Re: [JDBC] JPA + enum == Exception |
| Дата | |
| Msg-id | 28690.1360299322@sss.pgh.pa.us обсуждение |
| Ответ на | Re: [JDBC] JPA + enum == Exception (Tom Dunstan <pgsql@tomd.cc>) |
| Ответы |
Re: [JDBC] JPA + enum == Exception
Re: [JDBC] JPA + enum == Exception |
| Список | pgsql-hackers |
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
В списке pgsql-hackers по дате отправления: