Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-dev] PostgreSQL database enum types

The PostgreSQL system allows users to define custom enum types that
can then be used in column definitions, very similar to Java enums,
and Hibernate has recently made it possible to use database enum types
to back JPA enum fields; does EclipseLink offer similar functionality,
and if not, can it be easily modified?

Essentially, if a column is declared as an enum type, Postgres maps an
incoming INSERT or UPDATE string value onto one of the user-defined
enum values, so a statement writing an enum value looks exactly like
writing a string value.  On a SELECT, the Postgres JDBC driver returns
a PGobject for the enum value, but the PGobject's getString/getInt
methods return the enum's string name and ordinal value.  When using
the EnumType.STRING strategy, writing enum values to the database Just
Works, and reading them back also works if getString is used to read
the value from the ResultSet (instead of some other strategy like
using getObject and then casting the result).  Is EclipseLink's STRING
strategy compatible with this approach?

Christopher Smith, CCNP, CCDP, MCP, LPIC-1
Sphere Systems

Back to the top