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
betold how to convert between the PGobject instance used by the JDBC driver and the Java enum value (or String, if
that'swhat 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@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Marc G. Fournier
Sent: Monday, December 17, 2012 6:02 PM
To: pgsql-jdbc@postgresql.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 ...
readingfrom the database isn't a problem, but there appears to be an issue with converting from string -> enum when
savingit 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'tthink of what to suggest ...
Is there a doc online I can maybe point them to about doing this ... ?