Sample Header Ad - 728x90

Can I set PostgreSQL "stringtype=unspecified" behavior as default?

3 votes
1 answer
9388 views
I am trying to get Hibernate to save Java enum fields as enum columns in PostgreSQL 9.6. If I map the fields as @Enumerated(STRING), Hibernate naively uses the enum name as the column contents. This works splendidly for reads (it just gets the string representation, matches up and returns), but the server complains about the type mismatch when writing: expression is of type character varying. [The PostgreSQL JDBC driver](https://jdbc.postgresql.org/documentation/94/connect.html) has a parameter stringtype that will tell the server to infer the appropriate column type for string values, and using stringtype=unspecified successfully gets enum values stored. However, I will be deploying my application in an environment where the JDBC connection string is supplied externally, and it's not practical to add the stringtype property to it. Is there a way I can configure the server (such as with a SET command) to treat connections as stringtype=unspecified by default?
Asked by chrylis -cautiouslyoptimistic- (131 rep)
May 17, 2017, 10:28 AM
Last activity: Nov 23, 2017, 06:35 PM