Re: JPA + enum == Exception

From: "Hudson, Derrick" <dhudson(at)redcom(dot)com>
To: "'Marc G(dot) Fournier'" <scrappy(at)hub(dot)org>, "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: JPA + enum == Exception
Date: 2012-12-18 14:25:50
Message-ID: 401084E5E73F4241A44F3C9E6FD794289CE24D03@exch-01
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc


The project I am working on uses enums in PostgreSQL and JPA/Eclipselink. Our entities use enums in the Java code as well. We ran into type handling issues like you describe, and solved them by writing converters. Eclipselink needs to be told how to convert between the PGobject instance used by the JDBC driver and the Java enum value (or String, if that's what you are using in the Java code).

http://www.eclipse.org/eclipselink/api/2.4/org/eclipse/persistence/mappings/converters/Converter.html

http://eclipse.org/eclipselink/documentation/2.4/jpa/extensions/a_converter.htm

-----Original Message-----
From: pgsql-jdbc-owner(at)postgresql(dot)org [mailto:pgsql-jdbc-owner(at)postgresql(dot)org] On Behalf Of Marc G. Fournier
Sent: Monday, December 17, 2012 6:02 PM
To: pgsql-jdbc(at)postgresql(dot)org
Subject: [JDBC] JPA + enum == Exception

I'm trying to use enum's in a database, but the java guys are telling me that they are having problems with inserts ... reading from the database isn't a problem, but there appears to be an issue with converting from string -> enum when saving it back again ...

they are using JPA2 / EJB + Eclipselink ... on the jboss side, we are running the latest jdbc driver ...

considering postgresql has always supported enum and extending types, I think they might be missing something, but I can't think of what to suggest ...

Is there a doc online I can maybe point them to about doing this ... ?

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2012-12-18 15:43:01 Re: Enabling Checksums
Previous Message Christoph Berg 2012-12-18 12:47:33 Re: configure.in and setproctitle/optreset problem

Browse pgsql-jdbc by date

  From Date Subject
Next Message zelaine 2012-12-20 19:23:13 BUG #7766: Running a DML statement that affects more than 4 billion rows results in an exception
Previous Message Craig Ringer 2012-12-18 00:29:32 Re: performance problem of Failover Datasource?