Re: [HACKERS] JPA + enum == Exception

Поиск
Список
Период
Сортировка
От Kris Jurka
Тема Re: [HACKERS] JPA + enum == Exception
Дата
Msg-id alpine.BSO.2.00.1302081124290.16163@leary.csoft.net
обсуждение исходный текст
Ответ на Re: [HACKERS] JPA + enum == Exception  (Tom Dunstan <tom@tomd.cc>)
Ответы Re: [HACKERS] JPA + enum == Exception  (Tom Dunstan <pgsql@tomd.cc>)
Список pgsql-jdbc

On Fri, 8 Feb 2013, Tom Dunstan wrote:

> On 8 February 2013 15:25, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> > 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.)
> >
>
> Yes, you can use setObject(1, "enumval", Types.OTHER). I was hoping
> that setString might work, as mapping java enum values to strings in
> the database is a very common ORM technique that is built into
> basically all major ORMs including all that support the JPA standard,
> and it leads to people using varchars instead of typesafe enums in
> their dbs.

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.

Kris Jurka



В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: Publish artifacts to Maven central
Следующее
От: Stephen Nelson
Дата:
Сообщение: Re: Publish artifacts to Maven central