Document mapping persistent enums against PostgreSQL enum types
Description
relates to
Activity
Steve Ebersole June 2, 2017 at 3:15 PM
Thanks for letting us know !
I think in general we just want to be recommending that people use pgjdbc-ng driver rather than the awful pgjdbc driver...

nate fredette May 19, 2017 at 5:55 PM
FWIW, I was running up against this very issue with enums and I have had a chance to play with the pgjdbc-ng driver mentioned above, and it appears that @Enumerated(EnumType.STRING) enum fields will map to db enums right out of the box with this driver.
Steve Ebersole January 19, 2016 at 6:18 PM
Unscheduling. Cannot really document this until we get some feedback from users running against PostgreSQL.
Steve Ebersole December 16, 2015 at 5:44 PM
Also I wonder if the problem really isn't simply a conceptual mismatch problem. You are asking Hibernate to treat the enum at the JDBC-level as a String (@Enumerated(STRING)). But in the database it isn't a String; its a UDT.
Let me finish this thought...
Also I wonder if the problem really isn't simply a conceptual mismatch problem. You are asking Hibernate to treat the enum at the JDBC-level as a String (@Enumerated(STRING)). But in the database it isn't a String; its a UDT. At this point either the driver properly handles the conversion, or it doesn't. The PostgreSQL driver does not, apparently not unless you specify this setting.
The documentation is undergoing a massive change for 5.1. That coupled with a still-unclear picture here means I am going to push this task to 5.1. I really would like for someone to play around with the NG driver before then.

Christopher Smith November 18, 2015 at 4:32 AM
I'm not anticipating a chance to play with the NG driver soon; my queue's already dropping.
Regarding the conceptual mismatch--you're absolutely right that that's the case, but one of the reasons I like the current behavior is that I use the same entities with both PostgreSQL and H2 (for testing). Using a non-DB-specific configuration that gets translated to something that looks like a standard string on the database's end means that Hibernate is essentially agnostic as to the implementation detail of how the column is being stored. While I certainly understand the ontological appeal of using UDTs, I'm concerned that that would break transparent backend compatibility.
Details
Assignee
Former userFormer user(Deactivated)Reporter
Jannik JochemJannik JochemLabels
Priority
Major
Details
Details
Assignee

Reporter

I'm not quite certain if this a bug or a feature request. My Postgres schema looks like this:
The column is mapped like this:
Which results in the following exception when trying to persist an entity:
reports a problem when reading a Postgres enum using Hibernate / JPA and was fixed intermittently. However, from looking at the code of `org.hibernate.type.EnumType` in 4.3.5 it looks as if the fix was removed while refactoring and the problem I am seeing here may have been introduced in the same way. However, I am not certain if supporting native Postgres enums is within the scope for Hibernate. If this is not the case, please change or close this issue accordingly.
Thanks for your help.